Class: Bitcoin::P2P::Option
- Inherits:
-
Object
- Object
- Bitcoin::P2P::Option
- Defined in:
- lib/bitcoin/p2p/option.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#network ⇒ Object
Returns the value of attribute network.
Instance Method Summary collapse
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
6 7 8 |
# File 'lib/bitcoin/p2p/option.rb', line 6 def host @host end |
#network ⇒ Object
Returns the value of attribute network.
7 8 9 |
# File 'lib/bitcoin/p2p/option.rb', line 7 def network @network end |
Instance Method Details
#parse ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bitcoin/p2p/option.rb', line 9 def parse op = OptionParser.new do |opts| opts. = "Usage: bitcoin-p2p -h <host> -n <network>" opts.on("-h host", "--host host", "IP address of the connection destination.") do |v| self.host = v end opts.on("-n network", "--network network", "Network to connect to.(mainnet or testnet or signet)") do |v| self.network = v.to_sym end [host, network] end begin puts op.parse(ARGV) unless host puts "Specify the host to connect to via -h option." exit(1) end unless %w(mainnet testnet signet).include?(network.to_s) puts "The network option must be either mainnet, testnet, or signet." exit(1) end rescue OptionParser::InvalidOption => e puts e. end 4.times {ARGV.shift} end |