Class: Gort::UserAgentRule
Overview
User-agent rule.
Instance Attribute Summary
Attributes inherited from Rule
Formatting Methods collapse
-
#inspect ⇒ String
A human readable representation of the rule.
-
#pretty_print(pp) ⇒ void
Produces a pretty human readable representation of the rule.
Instance Method Summary collapse
-
#initialize(value) ⇒ UserAgentRule
constructor
A new instance of UserAgentRule.
-
#valid? ⇒ Boolean
Returns
true
if the value is a valid user agent.
Constructor Details
#initialize(value) ⇒ UserAgentRule
Returns a new instance of UserAgentRule.
8 9 10 |
# File 'lib/gort/user_agent_rule.rb', line 8 def initialize(value) super(:"user-agent", value) end |
Instance Method Details
#inspect ⇒ String
A human readable representation of the rule.
34 35 36 |
# File 'lib/gort/user_agent_rule.rb', line 34 def inspect %(#<#{self.class.name}:#{object_id} "#{value}">) end |
#pretty_print(pp) ⇒ void
This method returns an undefined value.
Produces a pretty human readable representation of the rule.
45 46 47 |
# File 'lib/gort/user_agent_rule.rb', line 45 def pretty_print(pp) pp.text("#{self.class.name}/#{object_id}< #{value} >") end |
#valid? ⇒ Boolean
Returns true
if the value is a valid user agent.
A user agent token is a sequence of letters (a—z, A—Z), digits (0—9), underscores (_), or hyphens (-). Alternatively, a single asterisk (*) is also allowed.
23 24 25 |
# File 'lib/gort/user_agent_rule.rb', line 23 def valid? value.match?(PRODUCT_TOKEN_RE) end |