Class: Transaction
- Inherits:
-
Object
- Object
- Transaction
- Defined in:
- lib/tulipmania/transaction.rb
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#qty ⇒ Object
readonly
Returns the value of attribute qty.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
-
#what ⇒ Object
readonly
Returns the value of attribute what.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(from, to, qty, what, id = SecureRandom.uuid) ⇒ Transaction
constructor
A new instance of Transaction.
- #to_h ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(from, to, qty, what, id = SecureRandom.uuid) ⇒ Transaction
Returns a new instance of Transaction.
7 8 9 10 11 12 13 |
# File 'lib/tulipmania/transaction.rb', line 7 def initialize( from, to, qty, what, id=SecureRandom.uuid ) @from = from @to = to @qty = qty @what = what # tulip name - change to name or title - why? why not? @id = id end |
Instance Attribute Details
#from ⇒ Object (readonly)
Returns the value of attribute from.
5 6 7 |
# File 'lib/tulipmania/transaction.rb', line 5 def from @from end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/tulipmania/transaction.rb', line 5 def id @id end |
#qty ⇒ Object (readonly)
Returns the value of attribute qty.
5 6 7 |
# File 'lib/tulipmania/transaction.rb', line 5 def qty @qty end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
5 6 7 |
# File 'lib/tulipmania/transaction.rb', line 5 def to @to end |
#what ⇒ Object (readonly)
Returns the value of attribute what.
5 6 7 |
# File 'lib/tulipmania/transaction.rb', line 5 def what @what end |
Class Method Details
.from_h(hash) ⇒ Object
15 16 17 |
# File 'lib/tulipmania/transaction.rb', line 15 def self.from_h( hash ) self.new *hash.values_at( 'from', 'to', 'qty', 'what', 'id' ) end |
Instance Method Details
#to_h ⇒ Object
19 20 21 |
# File 'lib/tulipmania/transaction.rb', line 19 def to_h { from: @from, to: @to, qty: @qty, what: @what, id: @id } end |
#valid? ⇒ Boolean
24 25 26 27 |
# File 'lib/tulipmania/transaction.rb', line 24 def valid? ## check signature in the future; for now always true true end |