Class: AVR::Value

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value = 0) ⇒ Value

Returns a new instance of Value.



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

def initialize(value = 0)
  @name = T.let(:Constant, Symbol)
  @value = T.let(value, Integer)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#valueObject

Returns the value of attribute value.



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

def value
  @value
end

Instance Method Details

#formatObject



21
22
23
# File 'lib/avr/value.rb', line 21

def format
  '%02x'
end

#inspectObject



41
42
43
# File 'lib/avr/value.rb', line 41

def inspect
  "#<#{self.class.name} #{self}>"
end

#to_iObject



31
32
33
# File 'lib/avr/value.rb', line 31

def to_i
  value.to_i
end

#to_sObject



36
37
38
# File 'lib/avr/value.rb', line 36

def to_s
  name.to_s
end

#value_hexObject



26
27
28
# File 'lib/avr/value.rb', line 26

def value_hex
  format % value
end