Class: ClassStatement
Overview
A parsed class statement
Contains the variables, class name, type
Instance Method Summary collapse
-
#name ⇒ Object
The name of the class.
-
#to_hash ⇒ Hash
Returns the class object as a hash.
-
#type ⇒ Object
The class type.
-
#variables ⇒ Array
Returns a list of variables.
Instance Method Details
#name ⇒ Object
The name of the class
21 22 23 |
# File 'lib/steamd/nodes/class_statement_node.rb', line 21 def name class_name.text_value end |
#to_hash ⇒ Hash
Returns the class object as a hash
12 13 14 15 16 17 18 |
# File 'lib/steamd/nodes/class_statement_node.rb', line 12 def to_hash { name: name, type: type, variables: variables } end |
#type ⇒ Object
The class type
ie class Test<EMsg::Blah> {}
28 29 30 31 32 |
# File 'lib/steamd/nodes/class_statement_node.rb', line 28 def type types = elements.select { |el| el.is_a?(ClassType) } type = types.first type&.value end |
#variables ⇒ Array
Returns a list of variables
37 38 39 40 41 42 43 44 45 |
# File 'lib/steamd/nodes/class_statement_node.rb', line 37 def variables declerations = [first_var] + other.elements.map(&:decleration) variables = declerations.select do |node| node.is_a?(Variable) end variables.map!(&:to_hash) end |