Class: Richard::CurlReply
- Inherits:
-
Object
- Object
- Richard::CurlReply
- Defined in:
- lib/richard_iii/curl_reply.rb
Instance Attribute Summary collapse
-
#missing ⇒ Object
readonly
Returns the value of attribute missing.
-
#surplus ⇒ Object
readonly
Returns the value of attribute surplus.
Instance Method Summary collapse
- #==(text) ⇒ Object
- #eql?(text) ⇒ Boolean
- #equals?(text) ⇒ Boolean
-
#initialize(text) ⇒ CurlReply
constructor
A new instance of CurlReply.
- #inspect ⇒ Object
- #matches?(expected) ⇒ Boolean
- #to_s ⇒ Object
- #use_pretty_xml ⇒ Object
Constructor Details
#initialize(text) ⇒ CurlReply
Returns a new instance of CurlReply.
5 6 7 8 9 |
# File 'lib/richard_iii/curl_reply.rb', line 5 def initialize(text) @text = text @missing = @surplus = [] @pretty = false end |
Instance Attribute Details
#missing ⇒ Object (readonly)
Returns the value of attribute missing.
3 4 5 |
# File 'lib/richard_iii/curl_reply.rb', line 3 def missing @missing end |
#surplus ⇒ Object (readonly)
Returns the value of attribute surplus.
3 4 5 |
# File 'lib/richard_iii/curl_reply.rb', line 3 def surplus @surplus end |
Instance Method Details
#==(text) ⇒ Object
39 |
# File 'lib/richard_iii/curl_reply.rb', line 39 def ==(text); self.eql? text; end |
#eql?(text) ⇒ Boolean
34 35 36 |
# File 'lib/richard_iii/curl_reply.rb', line 34 def eql?(text) strip(@text).eql? strip(text) end |
#equals?(text) ⇒ Boolean
38 |
# File 'lib/richard_iii/curl_reply.rb', line 38 def equals?(text); self.eql? text; end |
#inspect ⇒ Object
42 |
# File 'lib/richard_iii/curl_reply.rb', line 42 def inspect; to_s; end |
#matches?(expected) ⇒ Boolean
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/richard_iii/curl_reply.rb', line 15 def matches?(expected) actual_lines = strip(@text) expected_lines = parse(expected) matches = actual_lines.select do |line| expected_lines.any?{|it| it.matches?(line)} end expectations_that_did_not_match_anything = expected_lines.select do |expected| actual_lines.none?{|line| expected.matches?(line)} end @missing = expectations_that_did_not_match_anything.map(&:text) @surplus = actual_lines - matches return matches.size.eql? expected_lines.size end |
#to_s ⇒ Object
41 |
# File 'lib/richard_iii/curl_reply.rb', line 41 def to_s; @text; end |
#use_pretty_xml ⇒ Object
11 12 13 |
# File 'lib/richard_iii/curl_reply.rb', line 11 def use_pretty_xml @pretty = true; end |