Class: MOSAIK::Syntax::Constant
- Inherits:
-
Object
- Object
- MOSAIK::Syntax::Constant
- Defined in:
- lib/mosaik/syntax/constant.rb
Overview
Constant in the codebase
Instance Attribute Summary collapse
-
#descendants ⇒ Object
readonly
Returns the value of attribute descendants.
-
#methods ⇒ Object
readonly
Returns the value of attribute methods.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #add_method(method_name, file = nil, line_num = nil) ⇒ Object
- #hash ⇒ Object
-
#initialize(name, parent = nil) ⇒ Constant
constructor
A new instance of Constant.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, parent = nil) ⇒ Constant
Returns a new instance of Constant.
11 12 13 14 15 16 17 18 |
# File 'lib/mosaik/syntax/constant.rb', line 11 def initialize(name, parent = nil) @name = name @methods = {} @parent = parent @descendants = Set.new end |
Instance Attribute Details
#descendants ⇒ Object (readonly)
Returns the value of attribute descendants.
9 10 11 |
# File 'lib/mosaik/syntax/constant.rb', line 9 def descendants @descendants end |
#methods ⇒ Object (readonly)
Returns the value of attribute methods.
9 10 11 |
# File 'lib/mosaik/syntax/constant.rb', line 9 def methods @methods end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/mosaik/syntax/constant.rb', line 9 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
9 10 11 |
# File 'lib/mosaik/syntax/constant.rb', line 9 def parent @parent end |
Instance Method Details
#==(other) ⇒ Object
28 29 30 |
# File 'lib/mosaik/syntax/constant.rb', line 28 def ==(other) name == other.name end |
#add_method(method_name, file = nil, line_num = nil) ⇒ Object
20 21 22 |
# File 'lib/mosaik/syntax/constant.rb', line 20 def add_method(method_name, file = nil, line_num = nil) methods[method_name] = Method.new(self, method_name, file, line_num) end |
#hash ⇒ Object
24 25 26 |
# File 'lib/mosaik/syntax/constant.rb', line 24 def hash name.hash end |
#inspect ⇒ Object
36 37 38 |
# File 'lib/mosaik/syntax/constant.rb', line 36 def inspect "#<Constant #{self}>" end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/mosaik/syntax/constant.rb', line 32 def to_s "#{name} (#{methods.size} methods)" end |