Class: Giter8::Pair
- Inherits:
-
Object
- Object
- Giter8::Pair
- Defined in:
- lib/giter8/pair.rb
Overview
Pair represent a key-value property pair
Constant Summary collapse
- PLAIN_KEY =
/^[A-Za-z_][A-Za-z0-9_]*$/.freeze
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(key, value) ⇒ Pair
constructor
A new instance of Pair.
-
#truthy? ⇒ Boolean
Determines whether the Pair’s value contains a truthy value.
Constructor Details
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
8 9 10 |
# File 'lib/giter8/pair.rb', line 8 def key @key end |
#value ⇒ Object
Returns the value of attribute value.
8 9 10 |
# File 'lib/giter8/pair.rb', line 8 def value @value end |
Instance Method Details
#==(other) ⇒ Object
23 24 25 26 27 |
# File 'lib/giter8/pair.rb', line 23 def ==(other) same_pair = other.is_a?(Pair) && other.key == @key && other.value == @value same_hash = other.is_a?(Hash) && other == { @key => @value } same_hash || same_pair end |
#truthy? ⇒ Boolean
Determines whether the Pair’s value contains a truthy value. See Conditional.truthy?
19 20 21 |
# File 'lib/giter8/pair.rb', line 19 def truthy? Conditional.truthy? @value end |