Class: Capwatch::Fund::Config

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/capwatch/fund/config.rb

Defined Under Namespace

Classes: Demo, Local, Parser, Remote

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source: nil) ⇒ Config

Returns a new instance of Config.



13
14
15
16
# File 'lib/capwatch/fund/config.rb', line 13

def initialize(source: nil)
  @source = source || dynamic_source
  @parser = Parser.new(source: dynamic_source)
end

Instance Attribute Details

#parserObject (readonly)

Returns the value of attribute parser.



10
11
12
# File 'lib/capwatch/fund/config.rb', line 10

def parser
  @parser
end

#sourceObject (readonly)

Returns the value of attribute source.



10
11
12
# File 'lib/capwatch/fund/config.rb', line 10

def source
  @source
end

Instance Method Details

#coinsObject



22
23
24
25
26
27
28
29
# File 'lib/capwatch/fund/config.rb', line 22

def coins
  positions.map do |symbol, quantity|
    Coin.new do |coin|
      coin.symbol   = symbol
      coin.quantity = quantity
    end
  end
end

#demo?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/capwatch/fund/config.rb', line 31

def demo?
  name == Demo::NAME
end

#dynamic_sourceObject



18
19
20
# File 'lib/capwatch/fund/config.rb', line 18

def dynamic_source
  File.exist?(File.expand_path((Remote::FILE_NAME))) ? Remote.new : Local.new
end