Class: Rippler::Transaction
- Inherits:
-
Object
- Object
- Rippler::Transaction
show all
- Includes:
- Comparable, Utils
- Defined in:
- lib/rippler/transaction.rb
Overview
Represents a single Ripple transaction
Constant Summary
Constants included
from Utils
Utils::RIPPLE_TIME_OFFSET
Instance Method Summary
collapse
Methods included from Utils
#Account, #Money, #Offer, #Time
Constructor Details
7
8
9
|
# File 'lib/rippler/transaction.rb', line 7
def initialize data
@data = data
end
|
Instance Method Details
#amount ⇒ Object
20
21
22
|
# File 'lib/rippler/transaction.rb', line 20
def amount
Money(self.tx['Amount'])
end
|
#date ⇒ Object
36
37
38
|
# File 'lib/rippler/transaction.rb', line 36
def date
Time(tx['date'])
end
|
#dt ⇒ Object
32
33
34
|
# File 'lib/rippler/transaction.rb', line 32
def dt
self.tx['DestinationTag']
end
|
#from ⇒ Object
24
25
26
|
# File 'lib/rippler/transaction.rb', line 24
def from
self.tx['Account']
end
|
#timestring ⇒ Object
40
41
42
43
44
|
# File 'lib/rippler/transaction.rb', line 40
def timestring
if tx
"#{self.date.strftime("%Y-%m-%d %H:%M:%S")} "
end
end
|
#to ⇒ Object
28
29
30
|
# File 'lib/rippler/transaction.rb', line 28
def to
self.tx['Destination']
end
|
#to_s ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/rippler/transaction.rb', line 46
def to_s
if tx
timestring +
case tx["TransactionType"]
when "Payment"
"PAY #{Money(tx['Amount'])} #{Account(tx['Account'])} > #{Account(tx['Destination'])}"
when "OfferCancel"
"CAN #{Account(tx['Account'])} ##{tx['Sequence']}"
when "OfferCreate"
Offer(tx).to_s
when "TrustSet"
"TRS #{Money(tx['LimitAmount'])} #{Account(tx['Account'])}"
else
tx
end
else
@data
end
end
|
#tx ⇒ Object
Pure transaction data, without metadata
12
13
14
|
# File 'lib/rippler/transaction.rb', line 12
def tx
@data['tx'] || @data['transaction']
end
|
#type ⇒ Object
16
17
18
|
# File 'lib/rippler/transaction.rb', line 16
def type
self.tx['TransactionType']
end
|