Class: Linkscape::Response::ResponseData::Flags
- Inherits:
-
Object
- Object
- Linkscape::Response::ResponseData::Flags
- Defined in:
- lib/linkscape/response.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(bitfield, type) ⇒ Flags
constructor
A new instance of Flags.
- #to_a ⇒ Object
- #to_hash ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(bitfield, type) ⇒ Flags
Returns a new instance of Flags.
13 14 15 16 17 |
# File 'lib/linkscape/response.rb', line 13 def initialize(bitfield, type) @value = bitfield @flags = Linkscape::Constants::LinkMetrics::ResponseFlags.to_a.collect{|k,vv| k if (@value & vv[:flag]) == vv[:flag]}.compact if type == :link @flags = Linkscape::Constants::AnchorMetrics::ResponseFlags.to_a.collect{|k,vv| k if (@value & vv[:flag]) == vv[:flag]}.compact if type == :anchor end |
Instance Method Details
#[](key) ⇒ Object
18 |
# File 'lib/linkscape/response.rb', line 18 def [](key); @flags.include? key.to_sym; end |
#to_a ⇒ Object
19 |
# File 'lib/linkscape/response.rb', line 19 def to_a; @flags; end |
#to_hash ⇒ Object
20 |
# File 'lib/linkscape/response.rb', line 20 def to_hash; @flags.inject({}){|h,f|h[f]=true;h}; end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/linkscape/response.rb', line 21 def to_s %Q[#{@value}=#{self.to_a.inspect}] end |