Class: Whois::Record
- Inherits:
-
Object
- Object
- Whois::Record
- Defined in:
- lib/whois/record.rb,
lib/whois/record/part.rb
Defined Under Namespace
Classes: Part
Instance Attribute Summary collapse
-
#parts ⇒ Array<Whois::Record::Part>
readonly
The parts that compose this record.
-
#server ⇒ Whois::Server
readonly
The server that originated this record.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Returns true if the
object
is the same object, or is a string and has the same content. -
#content ⇒ String
Joins and returns all record parts into a single string and separates each response with a newline character.
-
#initialize(server, parts) ⇒ Record
constructor
Initializes a new instance with given
server
andparts
. -
#inspect ⇒ String
Returns a human-readable representation of this record.
- #match(pattern) ⇒ MatchData?
- #match?(pattern) ⇒ Boolean
-
#to_s ⇒ String
Returns a String representation of this record.
Constructor Details
#initialize(server, parts) ⇒ Record
Initializes a new instance with given server
and parts
.
32 33 34 35 |
# File 'lib/whois/record.rb', line 32 def initialize(server, parts) @parts = parts @server = server end |
Instance Attribute Details
#parts ⇒ Array<Whois::Record::Part> (readonly)
Returns The parts that compose this record.
24 25 26 |
# File 'lib/whois/record.rb', line 24 def parts @parts end |
#server ⇒ Whois::Server (readonly)
Returns The server that originated this record.
21 22 23 |
# File 'lib/whois/record.rb', line 21 def server @server end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Returns true if the object
is the same object, or is a string and has the same content.
60 61 62 63 64 65 66 67 68 |
# File 'lib/whois/record.rb', line 60 def ==(other) if equal?(other) true elsif other.is_a?(self.class) to_s == other.to_s else false end end |
#content ⇒ String
Joins and returns all record parts into a single string and separates each response with a newline character.
113 114 115 |
# File 'lib/whois/record.rb', line 113 def content @content ||= parts.map(&:body).join("\n") end |
#inspect ⇒ String
Returns a human-readable representation of this record.
50 51 52 |
# File 'lib/whois/record.rb', line 50 def inspect content.inspect end |
#match(pattern) ⇒ MatchData?
82 83 84 |
# File 'lib/whois/record.rb', line 82 def match(pattern) content.match(pattern) end |
#match?(pattern) ⇒ Boolean
94 95 96 |
# File 'lib/whois/record.rb', line 94 def match?(pattern) !content.match(pattern).nil? end |
#to_s ⇒ String
Returns a String representation of this record.
42 43 44 |
# File 'lib/whois/record.rb', line 42 def to_s content.to_s end |