Class: Capwatch::FundConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/capwatch/fund_config.rb

Constant Summary collapse

DEMO_CONFIG_NAME =
"Your Demo Fund"
DEMO_CONFIG_FILE =
"~/.capwatch"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_path = nil) ⇒ FundConfig

Returns a new instance of FundConfig.



11
12
13
14
# File 'lib/capwatch/fund_config.rb', line 11

def initialize(config_path = nil)
  @config_path = config_path || File.expand_path(DEMO_CONFIG_FILE)
  demo_config! unless config_exists?
end

Instance Attribute Details

#config_pathObject

Returns the value of attribute config_path.



9
10
11
# File 'lib/capwatch/fund_config.rb', line 9

def config_path
  @config_path
end

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/capwatch/fund_config.rb', line 9

def name
  @name
end

#positionsObject

Returns the value of attribute positions.



9
10
11
# File 'lib/capwatch/fund_config.rb', line 9

def positions
  @positions
end

Instance Method Details

#coinsObject



28
29
30
31
32
33
34
35
# File 'lib/capwatch/fund_config.rb', line 28

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

#demo?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/capwatch/fund_config.rb', line 37

def demo?
  name == DEMO_CONFIG_NAME
end

#parsed_configObject



24
25
26
# File 'lib/capwatch/fund_config.rb', line 24

def parsed_config
  parse @config_path
end