Class: Whois::Parsers::WhoisUa::Uaepp

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) ⇒ Uaepp

Returns a new instance of Uaepp.



22
23
24
25
# File 'lib/whois/parsers/whois.ua.rb', line 22

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

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



20
21
22
# File 'lib/whois/parsers/whois.ua.rb', line 20

def content
  @content
end

#parentObject (readonly)

Returns the value of attribute parent.



20
21
22
# File 'lib/whois/parsers/whois.ua.rb', line 20

def parent
  @parent
end

Instance Method Details

#build_contact(element, type) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/whois/parsers/whois.ua.rb', line 61

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(/contact-id:\s+#{contact_id}\n((?:.+\n)+)\n/, 1)

    address = textblock.scan(/address:\s+(.+)\n/).flatten
    address = address.reject { |a| a == "n/a" }

    Parser::Contact.new(
      type:         type,
      id:           contact_id,
      name:         textblock.slice(/person:\s+(.+)\n/, 1),
      organization: textblock.slice(/organization:\s+(.+)\n/, 1),
      address:      address.join("\n"),
      zip:          nil,
      state:        nil,
      city:         nil,
      country:      textblock.slice(/country:\s+(.+)\n/, 1),
      phone:        textblock.slice(/phone:\s+(.+)\n/, 1),
      fax:          textblock.slice(/fax:\s+(.+)\n/, 1),
      email:        textblock.slice(/e-mail:\s+(.+)\n/, 1),
      created_on:   Base.parse_time(textblock.slice(/created:\s+(.+)\n/, 1))
    )
  end
end

#created_onObject



42
43
44
45
46
# File 'lib/whois/parsers/whois.ua.rb', line 42

def created_on
  if content =~ /created:\s+(.+)\n/
    Base.parse_time(::Regexp.last_match(1))
  end
end

#expires_onObject



54
55
56
57
58
# File 'lib/whois/parsers/whois.ua.rb', line 54

def expires_on
  if content =~ /expires:\s+(.+)\n/
    Base.parse_time(::Regexp.last_match(1))
  end
end

#statusObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/whois/parsers/whois.ua.rb', line 27

def status
  if content =~ /status:\s+(.+?)\n/
    case (s = ::Regexp.last_match(1).downcase)
    when "ok", "clienthold", "autorenewgraceperiod", "clienttransferprohibited"
      :registered
    when "redemptionperiod", "pendingdelete"
      :redemption
    else
      Whois::Parser.bug!(ParserError, "Unknown status `#{s}'.")
    end
  else
    :available
  end
end

#updated_onObject



48
49
50
51
52
# File 'lib/whois/parsers/whois.ua.rb', line 48

def updated_on
  if content =~ /modified:\s+(.+)\n/
    Base.parse_time(::Regexp.last_match(1))
  end
end