Class: LocalPac::TranslationRule
- Inherits:
-
Object
- Object
- LocalPac::TranslationRule
- Defined in:
- lib/local_pac/translation_rule.rb
Instance Attribute Summary collapse
-
#network ⇒ Object
readonly
Returns the value of attribute network.
-
#requested_file ⇒ Object
readonly
Returns the value of attribute requested_file.
-
#rewritten_file ⇒ Object
readonly
Returns the value of attribute rewritten_file.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(options = {}) ⇒ TranslationRule
constructor
A new instance of TranslationRule.
- #match?(client_ip, file) ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ TranslationRule
Returns a new instance of TranslationRule.
7 8 9 10 11 12 13 |
# File 'lib/local_pac/translation_rule.rb', line 7 def initialize( = {}) @network = IPAddr.new(.fetch(:network)) @requested_file = .fetch(:requested_file) @rewritten_file = .fetch(:rewritten_file) rescue KeyError => err raise ArgumentError, err. end |
Instance Attribute Details
#network ⇒ Object (readonly)
Returns the value of attribute network.
5 6 7 |
# File 'lib/local_pac/translation_rule.rb', line 5 def network @network end |
#requested_file ⇒ Object (readonly)
Returns the value of attribute requested_file.
5 6 7 |
# File 'lib/local_pac/translation_rule.rb', line 5 def requested_file @requested_file end |
#rewritten_file ⇒ Object (readonly)
Returns the value of attribute rewritten_file.
5 6 7 |
# File 'lib/local_pac/translation_rule.rb', line 5 def rewritten_file @rewritten_file end |
Instance Method Details
#eql?(other) ⇒ Boolean
19 20 21 |
# File 'lib/local_pac/translation_rule.rb', line 19 def eql?(other) network == other.network && requested_file == other.requested_file end |
#hash ⇒ Object
23 24 25 |
# File 'lib/local_pac/translation_rule.rb', line 23 def hash [network, requested_file].hash end |
#match?(client_ip, file) ⇒ Boolean
15 16 17 |
# File 'lib/local_pac/translation_rule.rb', line 15 def match?(client_ip, file) network.include?(client_ip) && requested_file == file end |