Class: Capwatch::FundConfig
- Inherits:
-
Object
- Object
- Capwatch::FundConfig
- Defined in:
- lib/capwatch/fund_config.rb
Constant Summary collapse
- DEMO_CONFIG_NAME =
"Your Demo Fund"- DEMO_CONFIG_FILE =
"~/.capwatch"
Instance Attribute Summary collapse
-
#config_path ⇒ Object
Returns the value of attribute config_path.
-
#name ⇒ Object
Returns the value of attribute name.
-
#positions ⇒ Object
Returns the value of attribute positions.
Instance Method Summary collapse
- #coins ⇒ Object
- #demo? ⇒ Boolean
-
#initialize(config_path = nil) ⇒ FundConfig
constructor
A new instance of FundConfig.
- #parsed_config ⇒ Object
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.(DEMO_CONFIG_FILE) demo_config! unless config_exists? end |
Instance Attribute Details
#config_path ⇒ Object
Returns the value of attribute config_path.
9 10 11 |
# File 'lib/capwatch/fund_config.rb', line 9 def config_path @config_path end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/capwatch/fund_config.rb', line 9 def name @name end |
#positions ⇒ Object
Returns the value of attribute positions.
9 10 11 |
# File 'lib/capwatch/fund_config.rb', line 9 def positions @positions end |
Instance Method Details
#coins ⇒ Object
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
37 38 39 |
# File 'lib/capwatch/fund_config.rb', line 37 def demo? name == DEMO_CONFIG_NAME end |
#parsed_config ⇒ Object
24 25 26 |
# File 'lib/capwatch/fund_config.rb', line 24 def parsed_config parse @config_path end |