class DictClient::WordDefinitions
Attributes
definitions[R]
Public Class Methods
new(lines)
click to toggle source
Calls superclass method
DictClient::SimpleResponse::new
# File lib/dict_client/responses.rb, line 113 def initialize lines @definitions = [] super(lines) end
Public Instance Methods
count()
click to toggle source
# File lib/dict_client/responses.rb, line 134 def count @definitions.size end
to_s()
click to toggle source
# File lib/dict_client/responses.rb, line 130 def to_s @definitions.each_with_index.to_a.map{|definition, idx| definition.to_s(idx+1)}.join end
Private Instance Methods
process_line(line)
click to toggle source
# File lib/dict_client/responses.rb, line 140 def process_line line if line =~ /^#{RESPONSE_DEFINITION_FOLLOWS}\s+"([^\s+]+)"\s+([^\s+]+)\s+"(.+?)"/ word, dictionary_name, dictionary_description = $1, $2, $3 @current_definition = WordDefinition.new(word, dictionary_name, dictionary_description, '') @definitions << @current_definition else if @current_definition @current_definition.definition << line end end end