Class: Yaml::Sort::Alias
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #<=>(_other) ⇒ Object
- #delete_value ⇒ Object
-
#initialize(anchors, name) ⇒ Alias
constructor
A new instance of Alias.
- #to_s ⇒ Object
- #value? ⇒ Boolean
Methods inherited from Value
Constructor Details
#initialize(anchors, name) ⇒ Alias
Returns a new instance of Alias.
8 9 10 11 12 |
# File 'lib/yaml/sort/alias.rb', line 8 def initialize(anchors, name) super() @anchors = anchors @name = name[:value] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/yaml/sort/alias.rb', line 6 def name @name end |
Instance Method Details
#<=>(_other) ⇒ Object
34 35 36 |
# File 'lib/yaml/sort/alias.rb', line 34 def <=>(_other) 0 end |
#delete_value ⇒ Object
18 19 20 |
# File 'lib/yaml/sort/alias.rb', line 18 def delete_value @anchors.delete(@name) end |
#to_s ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/yaml/sort/alias.rb', line 22 def to_s(*) if (s = @anchors.delete(@name)) separator = case s when List, Dictionary then "\n" else " " end "&#{name}#{separator}#{s}" else "*#{name}" end end |
#value? ⇒ Boolean
14 15 16 |
# File 'lib/yaml/sort/alias.rb', line 14 def value? @anchors[@name] end |