Class: Resolv::LOC::Size
- Inherits:
-
Object
- Object
- Resolv::LOC::Size
- Defined in:
- lib/rubysl/resolv/resolv.rb
Overview
A Resolv::LOC::Size
Constant Summary collapse
- Regex =
/^(\d+\.*\d*)[m]$/
Instance Attribute Summary collapse
-
#scalar ⇒ Object
readonly
The raw size.
Class Method Summary collapse
-
.create(arg) ⇒ Object
Creates a new LOC::Size from
argwhich may be:.
Instance Method Summary collapse
-
#==(other) ⇒ Object
:nodoc:.
-
#eql?(other) ⇒ Boolean
:nodoc:.
-
#hash ⇒ Object
:nodoc:.
-
#initialize(scalar) ⇒ Size
constructor
A new instance of Size.
-
#inspect ⇒ Object
:nodoc:.
-
#to_s ⇒ Object
:nodoc:.
Constructor Details
#initialize(scalar) ⇒ Size
Returns a new instance of Size.
2642 2643 2644 |
# File 'lib/rubysl/resolv/resolv.rb', line 2642 def initialize(scalar) @scalar = scalar end |
Instance Attribute Details
#scalar ⇒ Object (readonly)
The raw size
2649 2650 2651 |
# File 'lib/rubysl/resolv/resolv.rb', line 2649 def scalar @scalar end |
Class Method Details
.create(arg) ⇒ Object
Creates a new LOC::Size from arg which may be:
- LOC::Size
-
returns
arg. - String
-
argmust match the LOC::Size::Regex constant
2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 |
# File 'lib/rubysl/resolv/resolv.rb', line 2625 def self.create(arg) case arg when Size return arg when String scalar = '' if Regex =~ arg scalar = [(($1.to_f*(1e2)).to_i.to_s[0].to_i*(2**4)+(($1.to_f*(1e2)).to_i.to_s.length-1))].pack("C") else raise ArgumentError.new("not a properly formed Size string: " + arg) end return Size.new(scalar) else raise ArgumentError.new("cannot interpret as Size: #{arg.inspect}") end end |
Instance Method Details
#==(other) ⇒ Object
:nodoc:
2660 2661 2662 |
# File 'lib/rubysl/resolv/resolv.rb', line 2660 def ==(other) # :nodoc: return @scalar == other.scalar end |
#eql?(other) ⇒ Boolean
:nodoc:
2664 2665 2666 |
# File 'lib/rubysl/resolv/resolv.rb', line 2664 def eql?(other) # :nodoc: return self == other end |
#hash ⇒ Object
:nodoc:
2668 2669 2670 |
# File 'lib/rubysl/resolv/resolv.rb', line 2668 def hash # :nodoc: return @scalar.hash end |
#inspect ⇒ Object
:nodoc:
2656 2657 2658 |
# File 'lib/rubysl/resolv/resolv.rb', line 2656 def inspect # :nodoc: return "#<#{self.class} #{self}>" end |
#to_s ⇒ Object
:nodoc:
2651 2652 2653 2654 |
# File 'lib/rubysl/resolv/resolv.rb', line 2651 def to_s # :nodoc: s = @scalar.unpack("H2").join.to_s return ((s[0].to_i)*(10**(s[1].to_i-2))).to_s << "m" end |