Class: Ssource::Source::Element
- Inherits:
-
Object
- Object
- Ssource::Source::Element
- Defined in:
- lib/ssource/source/element.rb
Instance Attribute Summary collapse
-
#accessibility ⇒ Object
readonly
Returns the value of attribute accessibility.
-
#body_length ⇒ Object
readonly
Returns the value of attribute body_length.
-
#body_offset ⇒ Object
readonly
Returns the value of attribute body_offset.
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#name_length ⇒ Object
readonly
Returns the value of attribute name_length.
-
#name_offset ⇒ Object
readonly
Returns the value of attribute name_offset.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
Instance Method Summary collapse
- #display_name ⇒ Object
-
#initialize(json) ⇒ Element
constructor
A new instance of Element.
- #pretty_print ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(json) ⇒ Element
Returns a new instance of Element.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ssource/source/element.rb', line 8 def initialize(json) @name = json['name'] @accessibility = json['accessibility'] @kind = json['kind'] @offset = json['offset'] @length = json['length'] @name_offset = json['nameoffset'] @name_length = json['namelength'] @body_offset = json['bodyoffset'] @body_length = json['bodylength'] @elements = json.fetch('substructure', []).reduce([]) do |arr, structure| arr << Factory.build(structure) end end |
Instance Attribute Details
#accessibility ⇒ Object (readonly)
Returns the value of attribute accessibility.
4 5 6 |
# File 'lib/ssource/source/element.rb', line 4 def accessibility @accessibility end |
#body_length ⇒ Object (readonly)
Returns the value of attribute body_length.
6 7 8 |
# File 'lib/ssource/source/element.rb', line 6 def body_length @body_length end |
#body_offset ⇒ Object (readonly)
Returns the value of attribute body_offset.
6 7 8 |
# File 'lib/ssource/source/element.rb', line 6 def body_offset @body_offset end |
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
4 5 6 |
# File 'lib/ssource/source/element.rb', line 4 def elements @elements end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
4 5 6 |
# File 'lib/ssource/source/element.rb', line 4 def kind @kind end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
6 7 8 |
# File 'lib/ssource/source/element.rb', line 6 def length @length end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/ssource/source/element.rb', line 4 def name @name end |
#name_length ⇒ Object (readonly)
Returns the value of attribute name_length.
6 7 8 |
# File 'lib/ssource/source/element.rb', line 6 def name_length @name_length end |
#name_offset ⇒ Object (readonly)
Returns the value of attribute name_offset.
6 7 8 |
# File 'lib/ssource/source/element.rb', line 6 def name_offset @name_offset end |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
6 7 8 |
# File 'lib/ssource/source/element.rb', line 6 def offset @offset end |
Instance Method Details
#display_name ⇒ Object
25 26 27 |
# File 'lib/ssource/source/element.rb', line 25 def display_name name end |
#pretty_print ⇒ Object
33 34 35 |
# File 'lib/ssource/source/element.rb', line 33 def pretty_print display_name end |
#to_hash ⇒ Object
29 30 31 |
# File 'lib/ssource/source/element.rb', line 29 def to_hash { 'name' => display_name } end |