Class: Calais::Response::Instance

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#exactObject

Returns the value of attribute exact.



48
49
50
# File 'lib/calais/response.rb', line 48

def exact
  @exact
end

#lengthObject

Returns the value of attribute length.



48
49
50
# File 'lib/calais/response.rb', line 48

def length
  @length
end

#offsetObject

Returns the value of attribute offset.



48
49
50
# File 'lib/calais/response.rb', line 48

def offset
  @offset
end

#prefixObject

Returns the value of attribute prefix.



48
49
50
# File 'lib/calais/response.rb', line 48

def prefix
  @prefix
end

#suffixObject

Returns the value of attribute suffix.



48
49
50
# File 'lib/calais/response.rb', line 48

def suffix
  @suffix
end

Class Method Details

.from_node(node) ⇒ Object

Makes a new Instance object from an appropriate Nokogiri::XML::Node.



51
52
53
54
55
56
57
58
59
60
# File 'lib/calais/response.rb', line 51

def self.from_node(node)
  instance = self.new
  instance.prefix = node.xpath("c:prefix[1]").first.content
  instance.exact  = node.xpath("c:exact[1]").first.content
  instance.suffix = node.xpath("c:suffix[1]").first.content
  instance.offset = node.xpath("c:offset[1]").first.content.to_i
  instance.length = node.xpath("c:length[1]").first.content.to_i

  instance
end