Class: ActiveWorksheet::Base
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- ActiveWorksheet::Base
- Extended by:
- ThreadsafeAttributes
- Defined in:
- lib/active_worksheet/base.rb
Class Method Summary collapse
- .adapter ⇒ Object
- .all ⇒ Object
- .count ⇒ Object
- .find(index) ⇒ Object
- .first ⇒ Object
- .is_source_local? ⇒ Boolean
- .is_source_remote? ⇒ Boolean
- .last ⇒ Object
Class Method Details
.adapter ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/active_worksheet/base.rb', line 35 def adapter if is_source_local? ActiveWorksheet::Adapters::FileAdapter.new(source: File.(source)) else ActiveWorksheet::Adapters::GoogleSheetsAdapter.new( source: source, authorization: ) end end |
.all ⇒ Object
13 14 15 16 17 |
# File 'lib/active_worksheet/base.rb', line 13 def all adapter.all.map do |row| new(row) end end |
.count ⇒ Object
31 32 33 |
# File 'lib/active_worksheet/base.rb', line 31 def count adapter.count end |
.find(index) ⇒ Object
19 20 21 |
# File 'lib/active_worksheet/base.rb', line 19 def find(index) new(adapter.find(index)) end |
.first ⇒ Object
23 24 25 |
# File 'lib/active_worksheet/base.rb', line 23 def first new(adapter.first) end |
.is_source_local? ⇒ Boolean
46 47 48 |
# File 'lib/active_worksheet/base.rb', line 46 def is_source_local? self.source.is_a?(File) || File.exists?(File.(self.source)) end |
.is_source_remote? ⇒ Boolean
50 51 52 |
# File 'lib/active_worksheet/base.rb', line 50 def is_source_remote? !is_source_local? end |
.last ⇒ Object
27 28 29 |
# File 'lib/active_worksheet/base.rb', line 27 def last new(adapter.last) end |