Class: MOSAIK::Syntax::Constant

Inherits:
Object
  • Object
show all
Defined in:
lib/mosaik/syntax/constant.rb

Overview

Constant in the codebase

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#descendantsObject (readonly)

Returns the value of attribute descendants.



9
10
11
# File 'lib/mosaik/syntax/constant.rb', line 9

def descendants
  @descendants
end

#methodsObject (readonly)

Returns the value of attribute methods.



9
10
11
# File 'lib/mosaik/syntax/constant.rb', line 9

def methods
  @methods
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/mosaik/syntax/constant.rb', line 9

def name
  @name
end

#parentObject (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

#hashObject



24
25
26
# File 'lib/mosaik/syntax/constant.rb', line 24

def hash
  name.hash
end

#inspectObject



36
37
38
# File 'lib/mosaik/syntax/constant.rb', line 36

def inspect
  "#<Constant #{self}>"
end

#to_sObject



32
33
34
# File 'lib/mosaik/syntax/constant.rb', line 32

def to_s
  "#{name} (#{methods.size} methods)"
end