Class: ItisItem

Inherits:
Object
  • Object
show all
Defined in:
lib/itis.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#descriptionObject

Returns the value of attribute description.



8
9
10
# File 'lib/itis.rb', line 8

def description
  @description
end

#textObject

Returns the value of attribute text.



8
9
10
# File 'lib/itis.rb', line 8

def text
  @text
end

#urlObject

Returns the value of attribute url.



8
9
10
# File 'lib/itis.rb', line 8

def url
  @url
end

Instance Method Details

#idObject



20
21
22
# File 'lib/itis.rb', line 20

def id
	Regexp.last_match[0] if @url.match(/\d+/) and person?
end

#person?Boolean

Returns:

  • (Boolean)


18
# File 'lib/itis.rb', line 18

def person?; (@url =~ /Person/i)? true: false end

#phonesObject



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_sObject



17
# File 'lib/itis.rb', line 17

def to_s; @text end