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.



53
54
55
# File 'lib/calais/response.rb', line 53

def exact
  @exact
end

#lengthObject

Returns the value of attribute length.



53
54
55
# File 'lib/calais/response.rb', line 53

def length
  @length
end

#offsetObject

Returns the value of attribute offset.



53
54
55
# File 'lib/calais/response.rb', line 53

def offset
  @offset
end

#prefixObject

Returns the value of attribute prefix.



53
54
55
# File 'lib/calais/response.rb', line 53

def prefix
  @prefix
end

#suffixObject

Returns the value of attribute suffix.



53
54
55
# File 'lib/calais/response.rb', line 53

def suffix
  @suffix
end

Class Method Details

.from_node(node) ⇒ Object

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



56
57
58
59
60
61
62
63
64
65
# File 'lib/calais/response.rb', line 56

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