Class: TextRazor::Sentence

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Sentence

Returns a new instance of Sentence.



7
8
9
10
11
12
# File 'lib/textrazor/sentence.rb', line 7

def initialize(params)
  @position = params[:position]
  @words = params[:words].map do |word_hash|
    Word.create_from_hash(word_hash)
  end
end

Instance Attribute Details

#positionObject (readonly)

Returns the value of attribute position.



5
6
7
# File 'lib/textrazor/sentence.rb', line 5

def position
  @position
end

#wordsObject (readonly)

Returns the value of attribute words.



5
6
7
# File 'lib/textrazor/sentence.rb', line 5

def words
  @words
end

Class Method Details

.create_from_hash(params) ⇒ Object



18
19
20
# File 'lib/textrazor/sentence.rb', line 18

def self.create_from_hash(params)
  new(params)
end

Instance Method Details

#number_of_wordsObject



14
15
16
# File 'lib/textrazor/sentence.rb', line 14

def number_of_words
  @words.size
end