Class: AVR::RegisterWithNamedBit

Inherits:
Value
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/avr/register_with_named_bit.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Value

#format, #inspect, #to_i, #to_s, #value_hex

Constructor Details

#initialize(register, named_bit) ⇒ RegisterWithNamedBit

Returns a new instance of RegisterWithNamedBit.



15
16
17
18
19
# File 'lib/avr/register_with_named_bit.rb', line 15

def initialize(register, named_bit)
  @register = register
  @named_bit = named_bit
  super()
end

Instance Attribute Details

#named_bitObject (readonly)

Returns the value of attribute named_bit.



12
13
14
# File 'lib/avr/register_with_named_bit.rb', line 12

def named_bit
  @named_bit
end

#registerObject (readonly)

Returns the value of attribute register.



9
10
11
# File 'lib/avr/register_with_named_bit.rb', line 9

def register
  @register
end

Instance Method Details

#nameObject



32
33
34
# File 'lib/avr/register_with_named_bit.rb', line 32

def name
  "#{register.name}.#{named_bit}"
end

#valueObject



22
23
24
# File 'lib/avr/register_with_named_bit.rb', line 22

def value
  register.fetch_bit(named_bit)
end

#value=(new_value) ⇒ Object



27
28
29
# File 'lib/avr/register_with_named_bit.rb', line 27

def value=(new_value)
  register.send("#{named_bit}=".to_sym, new_value)
end