Class: Scruber::Helpers::UserAgentRotator::UserAgent

Inherits:
Object
  • Object
show all
Defined in:
lib/scruber/helpers/user_agent_rotator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ UserAgent

Returns a new instance of UserAgent.



8
9
10
11
12
13
14
15
16
# File 'lib/scruber/helpers/user_agent_rotator.rb', line 8

def initialize(name, options={})
  @name = name
  raise Scruber::ArgumentError.new("You need to specify name") if @name.blank?
  @tags = options.fetch(:tags){ [] } || []
  if !@tags.is_a?(Array)
    @tags = [@tags]
  end
  @tags = @tags.compact.map(&:to_sym)
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/scruber/helpers/user_agent_rotator.rb', line 6

def name
  @name
end

#tagsObject

Returns the value of attribute tags.



6
7
8
# File 'lib/scruber/helpers/user_agent_rotator.rb', line 6

def tags
  @tags
end

Instance Method Details

#idObject



18
19
20
# File 'lib/scruber/helpers/user_agent_rotator.rb', line 18

def id
  @name
end