Class: Webcash::Public
- Inherits:
-
Object
- Object
- Webcash::Public
- Defined in:
- lib/webcash/public.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#hashed_value ⇒ Object
readonly
Returns the value of attribute hashed_value.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(amount, hashed_value) ⇒ Public
constructor
A new instance of Public.
- #is_equal(other) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(amount, hashed_value) ⇒ Public
9 10 11 12 13 |
# File 'lib/webcash/public.rb', line 9 def initialize(amount, hashed_value) Webcash::Helpers.validate_amount_decimals(amount) @amount = amount @hashed_value = hashed_value end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
7 8 9 |
# File 'lib/webcash/public.rb', line 7 def amount @amount end |
#hashed_value ⇒ Object (readonly)
Returns the value of attribute hashed_value.
7 8 9 |
# File 'lib/webcash/public.rb', line 7 def hashed_value @hashed_value end |
Class Method Details
.deserialize(webcash) ⇒ Object
15 16 17 |
# File 'lib/webcash/public.rb', line 15 def self.deserialize(webcash) Webcash::Helpers.deserialize_webcash(webcash) end |
Instance Method Details
#==(other) ⇒ Object
33 34 35 |
# File 'lib/webcash/public.rb', line 33 def ==(other) other.is_a?(Webcash::Public) && @amount == other.amount && @hashed_value == other.hashed_value end |
#is_equal(other) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/webcash/public.rb', line 19 def is_equal(other) if other.is_a?(Webcash::Secret) return true if @hashed_value == other.to_public.hashed_value elsif other.is_a?(Webcash::Public) return true if @hashed_value == other.hashed_value end false end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/webcash/public.rb', line 29 def to_s "e#{@amount.to_s('F').sub(/\.0+$/, '')}:public:#{@hashed_value}" end |