Class: Transaction

Inherits:
Object
  • Object
show all
Defined in:
lib/tulipmania/transaction.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#fromObject (readonly)

Returns the value of attribute from.



5
6
7
# File 'lib/tulipmania/transaction.rb', line 5

def from
  @from
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/tulipmania/transaction.rb', line 5

def id
  @id
end

#qtyObject (readonly)

Returns the value of attribute qty.



5
6
7
# File 'lib/tulipmania/transaction.rb', line 5

def qty
  @qty
end

#toObject (readonly)

Returns the value of attribute to.



5
6
7
# File 'lib/tulipmania/transaction.rb', line 5

def to
  @to
end

#whatObject (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_hObject



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

Returns:

  • (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