Class: OpenStax::Accounts::ActionList
- Inherits:
-
Object
- Object
- OpenStax::Accounts::ActionList
- Defined in:
- lib/openstax/accounts/action_list.rb
Instance Method Summary collapse
- #get_data(column, *args) ⇒ Object
- #get_heading(column) ⇒ Object
- #get_width(column) ⇒ Object
- #has_headings? ⇒ Boolean
-
#initialize(options = {}) ⇒ ActionList
constructor
A new instance of ActionList.
- #num_columns ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ ActionList
Returns a new instance of ActionList.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/openstax/accounts/action_list.rb', line 5 def initialize(={}) @options = raise IllegalArgument, "must supply data procs" if [:data_procs].nil? if [:headings].present? && [:data_procs].size != [:headings].size raise IllegalArgument, "if you supply headings, you must supply one for each column" end if [:widths].present? && [:data_procs].size != [:widths].size raise IllegalArgument, "if you supply widths, you must supply one for each column" end end |
Instance Method Details
#get_data(column, *args) ⇒ Object
36 37 38 |
# File 'lib/openstax/accounts/action_list.rb', line 36 def get_data(column, *args) @options[:data_procs][column].call(*args) end |
#get_heading(column) ⇒ Object
28 29 30 |
# File 'lib/openstax/accounts/action_list.rb', line 28 def get_heading(column) @options[:headings].nil? ? nil : @options[:headings][column] end |
#get_width(column) ⇒ Object
32 33 34 |
# File 'lib/openstax/accounts/action_list.rb', line 32 def get_width(column) @options[:widths].nil? ? nil : @options[:widths][column] end |
#has_headings? ⇒ Boolean
24 25 26 |
# File 'lib/openstax/accounts/action_list.rb', line 24 def has_headings? @options[:headings].present? end |
#num_columns ⇒ Object
20 21 22 |
# File 'lib/openstax/accounts/action_list.rb', line 20 def num_columns @options[:data_procs].size end |