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.
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
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.
5 6 7 8 9 10 11 12 13 |
# File 'lib/ssource/source/element.rb', line 5 def initialize(json) @name = json['name'] @accessibility = json['accessibility'] @kind = json['kind'] @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 |
#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 |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/ssource/source/element.rb', line 4 def name @name end |
Instance Method Details
#display_name ⇒ Object
15 16 17 |
# File 'lib/ssource/source/element.rb', line 15 def display_name name end |
#pretty_print ⇒ Object
23 24 25 |
# File 'lib/ssource/source/element.rb', line 23 def pretty_print dispay_name end |
#to_hash ⇒ Object
19 20 21 |
# File 'lib/ssource/source/element.rb', line 19 def to_hash { 'name' => display_name } end |