Class: SlowBlink::Message::STRING Abstract
- Inherits:
-
Object
- Object
- SlowBlink::Message::STRING
- Defined in:
- lib/slow_blink/message/string.rb
Overview
This class is abstract.
Class Method Summary collapse
-
.size ⇒ Integer?
Maximum size of string in bytes.
- .type ⇒ Object
Instance Method Summary collapse
- #get ⇒ String
-
#initialize(value) ⇒ STRING
constructor
A new instance of STRING.
-
#set(value) ⇒ Object
Set a string value.
- #to_tag ⇒ Object
Constructor Details
Class Method Details
.size ⇒ Integer?
Returns maximum size of string in bytes.
45 46 47 |
# File 'lib/slow_blink/message/string.rb', line 45 def self.size @type.size end |
.type ⇒ Object
27 28 29 |
# File 'lib/slow_blink/message/string.rb', line 27 def self.type @type end |
Instance Method Details
#get ⇒ String
50 51 52 |
# File 'lib/slow_blink/message/string.rb', line 50 def get @value end |
#set(value) ⇒ Object
Set a string value
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/slow_blink/message/string.rb', line 58 def set(value) if value.kind_of? String if !self.class.size or value.size <= self.class.size @value = value.to_s else raise RangeError.new "String instance cannot be larger than #{self.class.size} bytes" end else raise TypeError.new "expecting a String instance" end end |
#to_tag ⇒ Object
80 81 82 |
# File 'lib/slow_blink/message/string.rb', line 80 def to_tag @value end |