Class: Portable::Data::Source

Inherits:
Object
  • Object
show all
Defined in:
lib/portable/data/source.rb

Overview

A single source of data. This is meant to serve as an interface / example implementation with the intention of being re-implemented within applications. For example, you may decide more database data sources would be better, so it could be connected to ORMs or other data adapters; all it really needs to provide is enumerables for each attribute.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name: '', header_rows: [], footer_rows: [], data_rows: [], keys: []) ⇒ Source

Individial header and footer rows are arrays, while individual data_rows is an object like a hash, Struct, OpenStruct, or really any PORO.



27
28
29
30
31
32
33
34
35
# File 'lib/portable/data/source.rb', line 27

def initialize(name: '', header_rows: [], footer_rows: [], data_rows: [], keys: [])
  @name        = name.to_s
  @header_rows = header_rows || []
  @footer_rows = footer_rows || []
  @data_rows   = data_rows   || []
  @keys        = keys        || []

  freeze
end

Instance Attribute Details

#data_rowsObject (readonly)

Returns the value of attribute data_rows.



19
20
21
# File 'lib/portable/data/source.rb', line 19

def data_rows
  @data_rows
end

Returns the value of attribute footer_rows.



19
20
21
# File 'lib/portable/data/source.rb', line 19

def footer_rows
  @footer_rows
end

#header_rowsObject (readonly)

Returns the value of attribute header_rows.



19
20
21
# File 'lib/portable/data/source.rb', line 19

def header_rows
  @header_rows
end

#keysObject (readonly)

Returns the value of attribute keys.



19
20
21
# File 'lib/portable/data/source.rb', line 19

def keys
  @keys
end

#nameObject (readonly)

Returns the value of attribute name.



19
20
21
# File 'lib/portable/data/source.rb', line 19

def name
  @name
end