Class: Bataille::Site
- Inherits:
-
Object
- Object
- Bataille::Site
- Defined in:
- lib/bataille/site.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#rank ⇒ Object
Returns the value of attribute rank.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
-
#word ⇒ Object
Returns the value of attribute word.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Site
constructor
A new instance of Site.
- #word_count(attr) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Site
Returns a new instance of Site.
6 7 8 9 |
# File 'lib/bataille/site.rb', line 6 def initialize(args={}) @rank, @title, @url, @description, @keyword = args[:rank], args[:title], args[:url], args[:description], args[:keyword] end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/bataille/site.rb', line 4 def description @description end |
#rank ⇒ Object
Returns the value of attribute rank.
4 5 6 |
# File 'lib/bataille/site.rb', line 4 def rank @rank end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/bataille/site.rb', line 4 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/bataille/site.rb', line 4 def url @url end |
#word ⇒ Object
Returns the value of attribute word.
4 5 6 |
# File 'lib/bataille/site.rb', line 4 def word @word end |
Instance Method Details
#word_count(attr) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/bataille/site.rb', line 11 def word_count(attr) if [:title, :url, :description].include? attr.to_sym self.send(attr).scan(/#{@keyword}/i).length else raise ArgumentError end end |