Class: Capwatch::Fund::Config
- Inherits:
-
Object
- Object
- Capwatch::Fund::Config
- Extended by:
- Forwardable
- Defined in:
- lib/capwatch/fund/config.rb
Defined Under Namespace
Classes: Demo, Local, Parser, Remote
Instance Attribute Summary collapse
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #coins ⇒ Object
- #demo? ⇒ Boolean
- #dynamic_source ⇒ Object
-
#initialize(source: nil) ⇒ Config
constructor
A new instance of Config.
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
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
10 11 12 |
# File 'lib/capwatch/fund/config.rb', line 10 def parser @parser end |
#source ⇒ Object (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
#coins ⇒ Object
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
31 32 33 |
# File 'lib/capwatch/fund/config.rb', line 31 def demo? name == Demo::NAME end |
#dynamic_source ⇒ Object
18 19 20 |
# File 'lib/capwatch/fund/config.rb', line 18 def dynamic_source File.exist?(File.((Remote::FILE_NAME))) ? Remote.new : Local.new end |