Class: Gort::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/gort/rule.rb

Overview

Generic rule. This represents an entry that looks like a valid rule but otherwise doesn’t have a more specialized implementation.

Direct Known Subclasses

PathRule, UserAgentRule

Instance Attribute Summary collapse

Formatting Methods collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, value) ⇒ Rule

Returns a new instance of Rule.

Parameters:

  • name (Symbol)

    The name of the rule.

  • value (String)

    The value of the rule.



10
11
12
13
# File 'lib/gort/rule.rb', line 10

def initialize(name, value)
  @name = name.downcase.to_sym
  @value = value
end

Instance Attribute Details

#nameSymbol (readonly)

The name of the rule.

Returns:

  • (Symbol)


17
18
19
# File 'lib/gort/rule.rb', line 17

def name
  @name
end

#valueString (readonly)

The value of the rule.

Returns:

  • (String)


21
22
23
# File 'lib/gort/rule.rb', line 21

def value
  @value
end

Instance Method Details

#inspectString

A human readable representation of the rule.

Returns:

  • (String)


30
31
32
# File 'lib/gort/rule.rb', line 30

def inspect
  %(#<#{self.class.name}:#{object_id} "#{name}", "#{value}">)
end

#pretty_print(pp) ⇒ void

This method returns an undefined value.

Produces a pretty human readable representation of the rule.

Parameters:

  • pp (PrettyPrint)

    pretty printer



41
42
43
# File 'lib/gort/rule.rb', line 41

def pretty_print(pp)
  pp.text("#{self.class.name}/#{object_id}< #{name.inspect}, #{value} >")
end