You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
560 B
Ruby
29 lines
560 B
Ruby
11 years ago
|
class FrameDiff
|
||
|
|
||
|
def initialize(line_changes, cursor_changes)
|
||
|
@line_changes = line_changes
|
||
|
@cursor_changes = cursor_changes
|
||
|
end
|
||
|
|
||
|
def as_json(*)
|
||
|
json = {}
|
||
|
json[:lines] = optimized_line_changes unless line_changes.blank?
|
||
|
json[:cursor] = cursor_changes unless cursor_changes.blank?
|
||
|
|
||
|
json
|
||
|
end
|
||
|
|
||
|
private
|
||
|
|
||
|
attr_reader :line_changes, :cursor_changes
|
||
|
|
||
|
def optimized_line_changes
|
||
|
line_optimizer = LineOptimizer.new
|
||
|
|
||
|
line_changes.each_with_object({}) do |(k, v), h|
|
||
|
h[k] = line_optimizer.optimize(v)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
end
|