Class: Bataille::Category
- Inherits:
-
Object
- Object
- Bataille::Category
- Defined in:
- lib/bataille/category.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#words ⇒ Object
Returns the value of attribute words.
Instance Method Summary collapse
- #&(category) ⇒ Object
- #google_search(limit = 10) ⇒ Object
-
#initialize(name, words = []) ⇒ Category
constructor
A new instance of Category.
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
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/bataille/category.rb', line 4 def name @name end |
#words ⇒ Object
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 |