Class: Whois::Parsers::WhoisUa::Uanic

Inherits:
Object
  • Object
show all
Defined in:
lib/whois/parsers/whois.ua.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, content) ⇒ Uanic

Returns a new instance of Uanic.



93
94
95
96
# File 'lib/whois/parsers/whois.ua.rb', line 93

def initialize(parent, content)
  @parent  = parent
  @content = content
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



91
92
93
# File 'lib/whois/parsers/whois.ua.rb', line 91

def content
  @content
end

#parentObject (readonly)

Returns the value of attribute parent.



91
92
93
# File 'lib/whois/parsers/whois.ua.rb', line 91

def parent
  @parent
end

Instance Method Details

#build_contact(element, type) ⇒ Object



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/whois/parsers/whois.ua.rb', line 133

def build_contact(element, type)
  contact_ids = content.scan(/#{element}:\s+(.+)\n/).flatten
  return if contact_ids.empty?

  contact_ids.map do |contact_id|
    textblock = content.slice(/nic-handle:\s+#{contact_id}\n((?:.+\n)+)\n/, 1)

    address = textblock.scan(/address:\s+(.+)\n/).flatten
    zip = nil
    zip = address[1].slice!(/\s+\d{5}/).strip if address[1] =~ /\s+\d{5}/
    zip = address[1].slice!(/\d{5}\s+/).strip if address[1] =~ /\d{5}\s+/
    state = nil
    state = address[1].slice!(/\s+[A-Z]{2}\z/).strip if address[1] =~ /\s+[A-Z]{2}\z/

    Parser::Contact.new(
      type:         type,
      id:           contact_id,
      name:         nil,
      organization: textblock.scan(/organization:\s+(.+)\n/).join("\n"),
      address:      address[0],
      zip:          zip,
      state:        state,
      city:         address[1],
      country:      address[2],
      phone:        textblock.slice(/phone:\s+(.+)\n/, 1),
      fax:          textblock.slice(/fax-no:\s+(.+)\n/, 1),
      email:        textblock.slice(/e-mail:\s+(.+)\n/, 1),
      updated_on:   (Base.parse_time($1.split(" ").last) if textblock =~ /changed:\s+(.+)\n/)
    )
  end
end

#created_onObject



111
112
113
114
115
116
# File 'lib/whois/parsers/whois.ua.rb', line 111

def created_on
  if content =~ /created:\s+(.+)\n/
    time = $1.split(" ").last
    Base.parse_time(time)
  end
end

#expires_onObject



125
126
127
128
129
130
# File 'lib/whois/parsers/whois.ua.rb', line 125

def expires_on
  if content =~ /status:\s+(.+)\n/
    time = $1.split(" ").last
    Base.parse_time(time)
  end
end

#statusObject



98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/whois/parsers/whois.ua.rb', line 98

def status
  if content =~ /status:\s+(.+?)\n/
    case (s = $1.downcase)
    when /^ok-until/
      :registered
    else
      Whois.bug!(ParserError, "Unknown status `#{s}'.")
    end
  else
    :available
  end
end

#updated_onObject



118
119
120
121
122
123
# File 'lib/whois/parsers/whois.ua.rb', line 118

def updated_on
  if content =~ /changed:\s+(.+)\n/
    time = $1.split(" ").last
    Base.parse_time(time)
  end
end