Class: Yaml::Sort::Scalar
Direct Known Subclasses
Instance Attribute Summary collapse
-
#indent ⇒ Object
readonly
Returns the value of attribute indent.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(value) ⇒ Scalar
constructor
A new instance of Scalar.
- #to_s(skip_first_indent: false) ⇒ Object
Methods inherited from Value
Constructor Details
#initialize(value) ⇒ Scalar
Returns a new instance of Scalar.
8 9 10 11 12 13 |
# File 'lib/yaml/sort/scalar.rb', line 8 def initialize(value) super() @comment = value[:comment] || [] @value = value[:value] @indent = value[:indent] || "" end |
Instance Attribute Details
#indent ⇒ Object (readonly)
Returns the value of attribute indent.
6 7 8 |
# File 'lib/yaml/sort/scalar.rb', line 6 def indent @indent end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
6 7 8 |
# File 'lib/yaml/sort/scalar.rb', line 6 def value @value end |
Instance Method Details
#<=>(other) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/yaml/sort/scalar.rb', line 15 def <=>(other) if other.is_a?(Scalar) value <=> other.value else 0 end end |
#to_s(skip_first_indent: false) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/yaml/sort/scalar.rb', line 23 def to_s(skip_first_indent: false) if skip_first_indent super + value else super + indent + value end end |