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
objectis 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
serverandparts. -
#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.
29 30 31 32 |
# File 'lib/whois/record.rb', line 29 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.
21 22 23 |
# File 'lib/whois/record.rb', line 21 def parts @parts end |
#server ⇒ Whois::Server (readonly)
Returns The server that originated this record.
18 19 20 |
# File 'lib/whois/record.rb', line 18 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.
57 58 59 60 61 62 63 64 65 |
# File 'lib/whois/record.rb', line 57 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.
110 111 112 |
# File 'lib/whois/record.rb', line 110 def content @content ||= parts.map(&:body).join("\n") end |
#inspect ⇒ String
Returns a human-readable representation of this record.
47 48 49 |
# File 'lib/whois/record.rb', line 47 def inspect content.inspect end |
#match(pattern) ⇒ MatchData?
79 80 81 |
# File 'lib/whois/record.rb', line 79 def match(pattern) content.match(pattern) end |
#match?(pattern) ⇒ Boolean
91 92 93 |
# File 'lib/whois/record.rb', line 91 def match?(pattern) !content.match(pattern).nil? end |
#to_s ⇒ String
Returns a String representation of this record.
39 40 41 |
# File 'lib/whois/record.rb', line 39 def to_s content.to_s end |