Class: Hypesets::Client
- Inherits:
-
Object
- Object
- Hypesets::Client
- Defined in:
- lib/hypesets/client.rb
Instance Method Summary collapse
- #add(set_name, element) ⇒ Object
- #estimate(start_name, end_name) ⇒ Object
-
#initialize(hostname = 'localhost', port = 30303) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(hostname = 'localhost', port = 30303) ⇒ Client
Returns a new instance of Client.
7 8 9 10 |
# File 'lib/hypesets/client.rb', line 7 def initialize(hostname = 'localhost', port = 30303) @hostname = hostname @port = port end |
Instance Method Details
#add(set_name, element) ⇒ Object
12 13 14 15 16 |
# File 'lib/hypesets/client.rb', line 12 def add(set_name, element) connection.puts "ADD #{set_name} #{element}" :ok if fetch_response == "DONE\n" end |
#estimate(start_name, end_name) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/hypesets/client.rb', line 18 def estimate(start_name, end_name) connection.puts "ESTIMATE #{start_name} #{end_name}" fetch_response.split("\n")[0..-2].map do |estimation| set_name, cardinality = estimation.split(',') Estimation.new set_name, cardinality.to_i end end |