Class: Bits::Bit
- Inherits:
-
Object
- Object
- Bits::Bit
- Defined in:
- lib/bits/bit.rb
Overview
Class containing data for a single bit.
Instance Attribute Summary collapse
-
#atom ⇒ Object
Returns the value of attribute atom.
-
#dependencies ⇒ Object
Returns the value of attribute dependencies.
Class Method Summary collapse
Instance Method Summary collapse
- #get_provider_data(provider_id) ⇒ Object
- #has_provider?(provider_id) ⇒ Boolean
-
#initialize(atom, provider_data, dependencies) ⇒ Bit
constructor
A new instance of Bit.
- #to_s ⇒ Object
Constructor Details
#initialize(atom, provider_data, dependencies) ⇒ Bit
Returns a new instance of Bit.
6 7 8 9 10 |
# File 'lib/bits/bit.rb', line 6 def initialize(atom, provider_data, dependencies) @atom = atom @provider_data = provider_data @dependencies = dependencies end |
Instance Attribute Details
#atom ⇒ Object
Returns the value of attribute atom.
4 5 6 |
# File 'lib/bits/bit.rb', line 4 def atom @atom end |
#dependencies ⇒ Object
Returns the value of attribute dependencies.
4 5 6 |
# File 'lib/bits/bit.rb', line 4 def dependencies @dependencies end |
Class Method Details
.eval(reader, atom) ⇒ Object
28 29 30 31 |
# File 'lib/bits/bit.rb', line 28 def self.eval(reader, atom) decl = BitDeclaration.eval reader self.new atom, decl.provider_data, decl.dependencies end |
Instance Method Details
#get_provider_data(provider_id) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/bits/bit.rb', line 20 def get_provider_data(provider_id) unless has_provider? provider_id raise "#{self} not provided by #{provider_id}" end @provider_data[provider_id] end |
#has_provider?(provider_id) ⇒ Boolean
16 17 18 |
# File 'lib/bits/bit.rb', line 16 def has_provider?(provider_id) @provider_data.has_key? provider_id end |
#to_s ⇒ Object
12 13 14 |
# File 'lib/bits/bit.rb', line 12 def to_s "<Bit atom=#{atom} dependencies=#{dependencies.inspect} provider_data=#{@provider_data.inspect}>" end |