Class: Verokrypto::Coinex

Inherits:
Source
  • Object
show all
Defined in:
lib/verokrypto/coinex.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Source

#fees

Constructor Details

#initialize(events) ⇒ Coinex

Returns a new instance of Coinex.



7
8
9
10
# File 'lib/verokrypto/coinex.rb', line 7

def initialize(events)
  super()
  @events = events
end

Instance Attribute Details

#eventsObject (readonly)

Returns the value of attribute events.



5
6
7
# File 'lib/verokrypto/coinex.rb', line 5

def events
  @events
end

Class Method Details

.from_xlsx(path) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/verokrypto/coinex.rb', line 12

def self.from_xlsx(path)
  fields, rows = Verokrypto::Xlsx.new(path).parse

  events = []
  rows.each do |row|
    values = {}
    fields.each do |field|
      values[field] = row.shift
    end

    events << to_event(values)
  end

  new events
end

.to_event(values) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/verokrypto/coinex.rb', line 28

def self.to_event(values)
  e = Verokrypto::Event.new :coinex
  e.original = values
  e.date = "#{values.fetch('Execution Time')} UTC"

  # from_amount:
  #   from_currency:
  #   to_amount:
  #   to_currency:

  # fee_amount: values.fetch("Fees")
  # fee_currency:

  # net_amount:
  # net_currency:

  # label:
  # description:
  # tx:

  e.fee = [
    values.fetch('Fees'),
    values.fetch('Fees Coin Type')
  ].join(' ')

  e
end