Class: Zold::Remotes::Remote
- Inherits:
-
Object
- Object
- Zold::Remotes::Remote
- Defined in:
- lib/zold/remotes.rb
Overview
One remote.
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #assert_code(code, response) ⇒ Object
- #assert_valid_score(score) ⇒ Object
- #http(path = '/') ⇒ Object
-
#initialize(host, port, score) ⇒ Remote
constructor
A new instance of Remote.
- #to_s ⇒ Object
Constructor Details
#initialize(host, port, score) ⇒ Remote
Returns a new instance of Remote.
50 51 52 53 54 |
# File 'lib/zold/remotes.rb', line 50 def initialize(host, port, score) @host = host @port = port @score = score end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
49 50 51 |
# File 'lib/zold/remotes.rb', line 49 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
49 50 51 |
# File 'lib/zold/remotes.rb', line 49 def port @port end |
Instance Method Details
#assert_code(code, response) ⇒ Object
65 66 67 |
# File 'lib/zold/remotes.rb', line 65 def assert_code(code, response) raise "#{response.code} \"#{response.}\" at \"#{response.body}\"" unless response.code.to_i == code end |
#assert_valid_score(score) ⇒ Object
69 70 71 72 |
# File 'lib/zold/remotes.rb', line 69 def assert_valid_score(score) raise "Invalid score #{score}" unless score.valid? raise "Expired score #{score}" if score.expired? end |
#http(path = '/') ⇒ Object
56 57 58 59 |
# File 'lib/zold/remotes.rb', line 56 def http(path = '/') uri = URI("http://#{@host}:#{@port}#{path}") Http.new(uri, @score) end |
#to_s ⇒ Object
61 62 63 |
# File 'lib/zold/remotes.rb', line 61 def to_s "#{@host}:#{@port}" end |