Class: Tapyrus::Node::Configuration
- Inherits:
-
Object
- Object
- Tapyrus::Node::Configuration
- Defined in:
- lib/tapyrus/node/configuration.rb
Instance Attribute Summary collapse
-
#conf ⇒ Object
readonly
Returns the value of attribute conf.
Instance Method Summary collapse
- #host ⇒ Object
-
#initialize(opts = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #port ⇒ Object
- #server_url ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Configuration
Returns a new instance of Configuration.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/tapyrus/node/configuration.rb', line 8 def initialize(opts = {}) # TODO apply configuration file. opts[:network] = :prod unless opts[:network] opts[:relay] = false unless opts[:relay] Tapyrus.chain_params = opts[:network] begin ini_file = IniParse.parse(File.read("#{Tapyrus.base_dir}/tapyrusrb.conf")) @conf = Hash[ini_file.to_h["__anonymous__"].map { |k, v| [k.to_sym, v] }] rescue => e @conf = {} end @conf.merge!(opts) end |
Instance Attribute Details
#conf ⇒ Object (readonly)
Returns the value of attribute conf.
6 7 8 |
# File 'lib/tapyrus/node/configuration.rb', line 6 def conf @conf end |
Instance Method Details
#host ⇒ Object
23 24 25 |
# File 'lib/tapyrus/node/configuration.rb', line 23 def host "localhost" end |
#port ⇒ Object
27 28 29 |
# File 'lib/tapyrus/node/configuration.rb', line 27 def port Tapyrus.chain_params.default_port - 1 end |
#server_url ⇒ Object
31 32 33 |
# File 'lib/tapyrus/node/configuration.rb', line 31 def server_url "http://#{host}:#{port}" end |