Class: Comet::EventListener

Inherits:
Object
  • Object
show all
Defined in:
lib/comet-html/parser-binding.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(el, parent, key, value) ⇒ EventListener

Returns a new instance of EventListener.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/comet-html/parser-binding.rb', line 7

def initialize el, parent, key, value
  @el             = el
  @parent         = parent
  @is_cpp         = key.start_with?("cpp::")
  @attribute_name = key.delete_suffix(".trigger")
  @attribute_name = @attribute_name[5..-1] if is_cpp
  @code           = value

  if @parent.find_reference_for(el).nil?
    @parent.refs << (Reference.new(el, @parent))
  end
end

Instance Attribute Details

#attribute_nameObject (readonly)

Returns the value of attribute attribute_name.



5
6
7
# File 'lib/comet-html/parser-binding.rb', line 5

def attribute_name
  @attribute_name
end

#codeObject (readonly)

Returns the value of attribute code.



5
6
7
# File 'lib/comet-html/parser-binding.rb', line 5

def code
  @code
end

#elObject (readonly)

Returns the value of attribute el.



5
6
7
# File 'lib/comet-html/parser-binding.rb', line 5

def el
  @el
end

#is_cppObject (readonly)

Returns the value of attribute is_cpp.



5
6
7
# File 'lib/comet-html/parser-binding.rb', line 5

def is_cpp
  @is_cpp
end