Class: Odin::Types::OdinDirective
- Inherits:
-
Object
- Object
- Odin::Types::OdinDirective
- Defined in:
- lib/odin/types/directive.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(name, value = nil) ⇒ OdinDirective
constructor
A new instance of OdinDirective.
- #to_s ⇒ Object
Constructor Details
#initialize(name, value = nil) ⇒ OdinDirective
Returns a new instance of OdinDirective.
8 9 10 11 12 |
# File 'lib/odin/types/directive.rb', line 8 def initialize(name, value = nil) @name = -name.to_s @value = value&.freeze freeze end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/odin/types/directive.rb', line 6 def name @name end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
6 7 8 |
# File 'lib/odin/types/directive.rb', line 6 def value @value end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
14 15 16 |
# File 'lib/odin/types/directive.rb', line 14 def ==(other) other.is_a?(OdinDirective) && name == other.name && value == other.value end |
#hash ⇒ Object
19 20 21 |
# File 'lib/odin/types/directive.rb', line 19 def hash [name, value].hash end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/odin/types/directive.rb', line 23 def to_s value ? "#{name}(#{value})" : name end |