Class: DMARC::Uri
- Inherits:
-
Object
- Object
- DMARC::Uri
- Defined in:
- lib/dmarc/uri.rb
Overview
Represents a DMARC URI.
Instance Attribute Summary collapse
-
#size ⇒ Integer?
readonly
The optional maximum-size.
-
#unit ⇒ :k, ...
readonly
The optional unit.
-
#uri ⇒ URI::MailTo
readonly
The
mailto:
URI.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Determines if the DMARC URI matches the other.
-
#initialize(uri, size = nil, unit = nil) ⇒ Uri
constructor
Initializes the DMARC URI.
-
#method_missing(name, *arguments, &block) ⇒ Object
protected
Pass all missing methods to #uri.
-
#size? ⇒ Boolean
Determines if a maximum-size was set.
-
#to_s ⇒ String
Converts the DMARC URI back into a String.
-
#unit? ⇒ Boolean
Determines if a size unit was set.
Constructor Details
#initialize(uri, size = nil, unit = nil) ⇒ Uri
Initializes the DMARC URI.
38 39 40 41 42 43 |
# File 'lib/dmarc/uri.rb', line 38 def initialize(uri,size=nil,unit=nil) @uri = uri @size = size @unit = unit end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *arguments, &block) ⇒ Object (protected)
Pass all missing methods to #uri.
100 101 102 |
# File 'lib/dmarc/uri.rb', line 100 def method_missing(name,*arguments,&block) @uri.send(name,*arguments,&block) end |
Instance Attribute Details
#size ⇒ Integer? (readonly)
The optional maximum-size.
19 20 21 |
# File 'lib/dmarc/uri.rb', line 19 def size @size end |
#unit ⇒ :k, ... (readonly)
The optional unit.
24 25 26 |
# File 'lib/dmarc/uri.rb', line 24 def unit @unit end |
#uri ⇒ URI::MailTo (readonly)
The mailto:
URI.
14 15 16 |
# File 'lib/dmarc/uri.rb', line 14 def uri @uri end |
Instance Method Details
#==(other) ⇒ Boolean
Determines if the DMARC URI matches the other.
71 72 73 74 75 76 |
# File 'lib/dmarc/uri.rb', line 71 def ==(other) (self.class == other.class) && (@uri == other.uri) && (@size == other.size) && (@unit == other.unit) end |
#size? ⇒ Boolean
Determines if a maximum-size was set.
50 51 52 |
# File 'lib/dmarc/uri.rb', line 50 def size? !@size.nil? end |
#to_s ⇒ String
Converts the DMARC URI back into a String.
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/dmarc/uri.rb', line 83 def to_s str = @uri.to_s if (@size || @unit) str << "!" str << "#{@size}" if @size str << "#{@unit}" if @unit end return str end |
#unit? ⇒ Boolean
Determines if a size unit was set.
59 60 61 |
# File 'lib/dmarc/uri.rb', line 59 def unit? !@unit.nil? end |