Class: Zget::Zput
Instance Attribute Summary collapse
-
#alias ⇒ Object
readonly
Returns the value of attribute alias.
-
#bind_address ⇒ Object
readonly
Returns the value of attribute bind_address.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(_alias: SecureRandom.hex(2), bind_address: "0.0.0.0", file:, port: 6666) ⇒ Zput
constructor
A new instance of Zput.
Constructor Details
#initialize(_alias: SecureRandom.hex(2), bind_address: "0.0.0.0", file:, port: 6666) ⇒ Zput
Returns a new instance of Zput.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/zget/command/zput.rb', line 5 def initialize(_alias: SecureRandom.hex(2), bind_address: "0.0.0.0", file:, port: 6666) @bind_address = IPAddr.new bind_address @file = file.tap do |f| raise InvalidFileError unless File.exist? f end @alias = _alias @port = port.tap do |p| raise InvalidPortError unless p.between? 0, 65535 end end |
Instance Attribute Details
#alias ⇒ Object (readonly)
Returns the value of attribute alias.
3 4 5 |
# File 'lib/zget/command/zput.rb', line 3 def alias @alias end |
#bind_address ⇒ Object (readonly)
Returns the value of attribute bind_address.
3 4 5 |
# File 'lib/zget/command/zput.rb', line 3 def bind_address @bind_address end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
3 4 5 |
# File 'lib/zget/command/zput.rb', line 3 def file @file end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
3 4 5 |
# File 'lib/zget/command/zput.rb', line 3 def port @port end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/zget/command/zput.rb', line 16 def call puts "Download this file using `zget #{File.basename file}` or `zget #{@alias}`" hashes.each do |hash| DNSSD.register hash, "_http._tcp", nil, port end server.start end |