Class: HashKey
- Defined in:
- ext/enterprise_script_service/mruby/test/t/hash.rb
Overview
Hash ISO Test
Instance Attribute Summary collapse
-
#callback ⇒ Object
Returns the value of attribute callback.
-
#error ⇒ Object
Returns the value of attribute error.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(value, error: nil, callback: nil) ⇒ HashKey
constructor
A new instance of HashKey.
- #raise_error(name) ⇒ Object
- #to_s ⇒ Object (also: #inspect)
Constructor Details
#initialize(value, error: nil, callback: nil) ⇒ HashKey
Returns a new instance of HashKey.
9 10 11 12 13 |
# File 'ext/enterprise_script_service/mruby/test/t/hash.rb', line 9 def initialize(value, error: nil, callback: nil) @value = value @error = error @callback = callback end |
Instance Attribute Details
#callback ⇒ Object
Returns the value of attribute callback.
5 6 7 |
# File 'ext/enterprise_script_service/mruby/test/t/hash.rb', line 5 def callback @callback end |
#error ⇒ Object
Returns the value of attribute error.
5 6 7 |
# File 'ext/enterprise_script_service/mruby/test/t/hash.rb', line 5 def error @error end |
#value ⇒ Object
Returns the value of attribute value.
5 6 7 |
# File 'ext/enterprise_script_service/mruby/test/t/hash.rb', line 5 def value @value end |
Instance Method Details
#==(other) ⇒ Object
15 16 17 18 19 |
# File 'ext/enterprise_script_service/mruby/test/t/hash.rb', line 15 def ==(other) @callback.(:==, self, other) if @callback return raise_error(:==) if @error == true || @error == :== other.kind_of?(self.class) && @value == other.value end |
#eql?(other) ⇒ Boolean
21 22 23 24 25 |
# File 'ext/enterprise_script_service/mruby/test/t/hash.rb', line 21 def eql?(other) @callback.(:eql?, self, other) if @callback return raise_error(:eql?) if @error == true || @error == :eql? other.kind_of?(self.class) && @value.eql?(other.value) end |
#hash ⇒ Object
27 28 29 30 31 |
# File 'ext/enterprise_script_service/mruby/test/t/hash.rb', line 27 def hash @callback.(:hash, self) if @callback return raise_error(:hash) if @error == true || @error == :hash @value % 3 end |
#raise_error(name) ⇒ Object
38 39 40 |
# File 'ext/enterprise_script_service/mruby/test/t/hash.rb', line 38 def raise_error(name) raise "##{self}: #{name} error" end |
#to_s ⇒ Object Also known as: inspect
33 34 35 |
# File 'ext/enterprise_script_service/mruby/test/t/hash.rb', line 33 def to_s "#{self.class}[#{@value}]" end |