Class: Black::HTMLView::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/black/html_view.rb

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Context

Returns a new instance of Context.



18
19
20
21
22
23
24
# File 'lib/black/html_view.rb', line 18

def initialize(data)
  data.each do |name, value|
    self.class.class_eval do
      define_method(name) { value }
    end
  end
end

Instance Method Details

#contentObject



33
34
35
# File 'lib/black/html_view.rb', line 33

def content
  @content ||= rogueify(diff.newer)
end

#get_bindingObject



38
39
40
# File 'lib/black/html_view.rb', line 38

def get_binding
  binding
end

#highlight(line) ⇒ Object

return syntax-highlighted version of the line



27
28
29
30
31
# File 'lib/black/html_view.rb', line 27

def highlight(line)
  line.deletion? ?
    older[line.old_line_number-1] :
    newer[line.new_line_number-1]
end