Class: Bataille::Site

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#descriptionObject

Returns the value of attribute description.



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

def description
  @description
end

#rankObject

Returns the value of attribute rank.



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

def rank
  @rank
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

#wordObject

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