Class: Teleinfo::Frame

Inherits:
Object
  • Object
show all
Defined in:
lib/teleinfo/frame.rb

Overview

Take an array of String to parse as a Téléinfo Frame

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lines) ⇒ Frame

Returns a new instance of Frame.



6
7
8
9
# File 'lib/teleinfo/frame.rb', line 6

def initialize(lines)
  fail ArgumentError.new('Must instanciate with a non empty array of String') if !lines.is_a?(Array) || lines.empty? || lines.any? { |line| !line.is_a?(String) }
  tokenize(lines)
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



4
5
6
# File 'lib/teleinfo/frame.rb', line 4

def errors
  @errors
end

Instance Method Details

#to_hashObject



11
12
13
# File 'lib/teleinfo/frame.rb', line 11

def to_hash
  @data
end

#to_jsonObject



15
16
17
# File 'lib/teleinfo/frame.rb', line 15

def to_json
  @data.to_json
end