Class: ItisItem
- Inherits:
-
Object
- Object
- ItisItem
- Defined in:
- lib/itis.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#text ⇒ Object
Returns the value of attribute text.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(element) ⇒ ItisItem
constructor
A new instance of ItisItem.
- #person? ⇒ Boolean
- #phones ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(element) ⇒ ItisItem
Returns a new instance of ItisItem.
10 11 12 13 14 15 |
# File 'lib/itis.rb', line 10 def initialize element @text = element.at("Text").content.strip @url = element.at("Url").content.strip @description = element.at("Description").content.strip self end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
8 9 10 |
# File 'lib/itis.rb', line 8 def description @description end |
#text ⇒ Object
Returns the value of attribute text.
8 9 10 |
# File 'lib/itis.rb', line 8 def text @text end |
#url ⇒ Object
Returns the value of attribute url.
8 9 10 |
# File 'lib/itis.rb', line 8 def url @url end |
Instance Method Details
#id ⇒ Object
20 21 22 |
# File 'lib/itis.rb', line 20 def id Regexp.last_match[0] if @url.match(/\d+/) and person? end |
#person? ⇒ Boolean
18 |
# File 'lib/itis.rb', line 18 def person?; (@url =~ /Person/i)? true: false end |
#phones ⇒ Object
24 25 26 |
# File 'lib/itis.rb', line 24 def phones out = HTTParty.get("http://www.itis.si/AAA-AAA?#{id}").parsed_response if person? end |
#to_s ⇒ Object
17 |
# File 'lib/itis.rb', line 17 def to_s; @text end |