Class: Gort::Group
Overview
An access group
Instance Attribute Summary
Attributes inherited from RuleSet
Formatting Methods collapse
-
#inspect ⇒ String
A human readable representation of the group.
-
#pretty_print(pp) ⇒ void
Produces a pretty human readable representation of the group.
Instance Method Summary collapse
-
#apply?(user_agent) ⇒ Boolean
Does this group apply to this specific user agent?.
-
#valid? ⇒ Boolean
Is this group valid?.
Methods inherited from RuleSet
Constructor Details
This class inherits a constructor from Gort::RuleSet
Instance Method Details
#apply?(user_agent) ⇒ Boolean
Does this group apply to this specific user agent?
This performa user agent matcchign acording to the RFC.
25 26 27 |
# File 'lib/gort/group.rb', line 25 def apply?(user_agent) apply_to_all? || user_agent.match?(user_agent_regexp) end |
#inspect ⇒ String
A human readable representation of the group.
36 37 38 |
# File 'lib/gort/group.rb', line 36 def inspect "#<#{self.class.name}:#{object_id} #{rules.inspect}>" end |
#pretty_print(pp) ⇒ void
This method returns an undefined value.
Produces a pretty human readable representation of the group.
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/gort/group.rb', line 47 def pretty_print(pp) pp.text("#{self.class.name}/#{object_id}") pp.group(1, "[", "]") do pp.breakable("") pp.seplist(rules) do |rule| pp.pp(rule) end pp.breakable("") end end |
#valid? ⇒ Boolean
Is this group valid?
A valid group has at least one valid user-agent rule.
14 15 16 17 |
# File 'lib/gort/group.rb', line 14 def valid? @valid ||= rules.any? { |rule| rule.is_a?(UserAgentRule) && rule.valid? } end |