Class: Cql::Protocol::QueryRequest
- Defined in:
- lib/cql/protocol/requests/query_request.rb
Instance Attribute Summary collapse
-
#consistency ⇒ Object
readonly
Returns the value of attribute consistency.
-
#cql ⇒ Object
readonly
Returns the value of attribute cql.
Attributes inherited from Request
Instance Method Summary collapse
- #eql?(rq) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(cql, consistency) ⇒ QueryRequest
constructor
A new instance of QueryRequest.
- #to_s ⇒ Object
- #write(io) ⇒ Object
Methods inherited from Request
change_stream_id, #encode_frame
Methods included from Encoding
#write_bytes, #write_consistency, #write_decimal, #write_double, #write_float, #write_int, #write_long, #write_long_string, #write_short, #write_short_bytes, #write_string, #write_string_list, #write_string_map, #write_uuid, #write_varint
Constructor Details
#initialize(cql, consistency) ⇒ QueryRequest
Returns a new instance of QueryRequest.
8 9 10 11 12 13 14 |
# File 'lib/cql/protocol/requests/query_request.rb', line 8 def initialize(cql, consistency) raise ArgumentError, %(No CQL given!) unless cql raise ArgumentError, %(No such consistency: #{consistency.inspect}) if consistency.nil? || !CONSISTENCIES.include?(consistency) super(7) @cql = cql @consistency = consistency end |
Instance Attribute Details
#consistency ⇒ Object (readonly)
Returns the value of attribute consistency.
6 7 8 |
# File 'lib/cql/protocol/requests/query_request.rb', line 6 def consistency @consistency end |
#cql ⇒ Object (readonly)
Returns the value of attribute cql.
6 7 8 |
# File 'lib/cql/protocol/requests/query_request.rb', line 6 def cql @cql end |
Instance Method Details
#eql?(rq) ⇒ Boolean Also known as: ==
25 26 27 |
# File 'lib/cql/protocol/requests/query_request.rb', line 25 def eql?(rq) self.class === rq && rq.cql.eql?(self.cql) && rq.consistency.eql?(self.consistency) end |
#hash ⇒ Object
30 31 32 |
# File 'lib/cql/protocol/requests/query_request.rb', line 30 def hash @h ||= (@cql.hash * 31) ^ consistency.hash end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/cql/protocol/requests/query_request.rb', line 21 def to_s %(QUERY "#@cql" #{@consistency.to_s.upcase}) end |
#write(io) ⇒ Object
16 17 18 19 |
# File 'lib/cql/protocol/requests/query_request.rb', line 16 def write(io) write_long_string(io, @cql) write_consistency(io, @consistency) end |