Class: Comet::Reference
- Inherits:
-
ReferenceBase
- Object
- ReferenceBase
- Comet::Reference
- Defined in:
- lib/comet-html/parser-reference.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#el ⇒ Object
readonly
Returns the value of attribute el.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(el, parent, mode = nil) ⇒ Reference
constructor
A new instance of Reference.
- #is_explicit? ⇒ Boolean
- #is_implicit? ⇒ Boolean
- #set_mode(mode) ⇒ Object
Methods inherited from ReferenceBase
#has_default_value?, #has_getter?, #has_initializer?, #has_setter?
Constructor Details
#initialize(el, parent, mode = nil) ⇒ Reference
Returns a new instance of Reference.
53 54 55 56 57 58 59 |
# File 'lib/comet-html/parser-reference.rb', line 53 def initialize el, parent, mode = nil el["_cheerp_ref"] = self @el = el @parent = parent @type = @parent.context.find_cpp_type el.name set_mode mode end |
Instance Attribute Details
#el ⇒ Object (readonly)
Returns the value of attribute el.
51 52 53 |
# File 'lib/comet-html/parser-reference.rb', line 51 def el @el end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
51 52 53 |
# File 'lib/comet-html/parser-reference.rb', line 51 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
51 52 53 |
# File 'lib/comet-html/parser-reference.rb', line 51 def type @type end |
Instance Method Details
#is_explicit? ⇒ Boolean
74 |
# File 'lib/comet-html/parser-reference.rb', line 74 def is_explicit? ; @mode == :explicit ; end |
#is_implicit? ⇒ Boolean
75 |
# File 'lib/comet-html/parser-reference.rb', line 75 def is_implicit? ; @mode == :implicit ; end |
#set_mode(mode) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/comet-html/parser-reference.rb', line 61 def set_mode mode if (mode.nil? && !@el["ref"].nil?) || (mode == :explicit) @mode = :explicit @name = @el["ref"].to_s unless is_valid_cpp_variable_name?(@name) raise ParseError.new(el, "ref `#{@name}` is not a valid c++ variable name") end else @mode = :implicit @name = "element_#{@parent.context.generate_new_ref_name}" end end |