Class: Bataille::Category

Inherits:
Object
  • Object
show all
Defined in:
lib/bataille/category.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, words = []) ⇒ Category

Returns a new instance of Category.



5
6
7
8
# File 'lib/bataille/category.rb', line 5

def initialize(name, words=[])
  @name = name
  @words = words
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/bataille/category.rb', line 4

def name
  @name
end

#wordsObject

Returns the value of attribute words.



4
5
6
# File 'lib/bataille/category.rb', line 4

def words
  @words
end

Instance Method Details

#&(category) ⇒ Object



10
11
12
13
14
# File 'lib/bataille/category.rb', line 10

def &(category)
  words = self.words.product(category.words).map { |x| x.join(" ") }
  name = "#{@name} x #{category.name}"
  self.class.new(name, words)
end

#google_search(limit = 10) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/bataille/category.rb', line 16

def google_search(limit=10)
  ResultSet.new(
    self.words.map do |word|
      Search.google_search(word, limit)
    end,
    @name
  )
end