Class: Agenda::WordArray

Inherits:
Array
  • Object
show all
Defined in:
lib/agenda/wordarray.rb

Instance Method Summary collapse

Instance Method Details

#get(string) ⇒ Object



14
15
16
17
18
19
# File 'lib/agenda/wordarray.rb', line 14

def get(string)
  self.each do |one_word|
    return one_word if one_word.word == string.downcase
  end
  return false
end

#has?(string) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
# File 'lib/agenda/wordarray.rb', line 8

def has?(string)
  result = get(string)
  return result unless result != false
  return true
end

#not_tag(the_tag) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/agenda/wordarray.rb', line 29

def not_tag(the_tag)
  result = WordArray.new
  self.each do |one_word|
    result << one_word unless one_word.has_tag? the_tag
  end
  result
end

#order!Object



3
4
5
6
# File 'lib/agenda/wordarray.rb', line 3

def order!
  self.sort_by! { |x| x.count || x.word }
  self.reverse!
end

#tag(the_tag) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/agenda/wordarray.rb', line 21

def tag(the_tag)
  result = WordArray.new
  self.each do |one_word|
    result << one_word if one_word.has_tag? the_tag
  end
  result
end