Class: Report::Body::Column
- Inherits:
-
Object
- Object
- Report::Body::Column
- Defined in:
- lib/report/body/column.rb
Instance Attribute Summary collapse
-
#blk ⇒ Object
readonly
Returns the value of attribute blk.
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#faded ⇒ Object
readonly
Returns the value of attribute faded.
-
#method_id ⇒ Object
readonly
Returns the value of attribute method_id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#row_options ⇒ Object
readonly
Returns the value of attribute row_options.
Instance Method Summary collapse
-
#initialize(*args, &blk) ⇒ Column
constructor
A new instance of Column.
- #read(report, obj) ⇒ Object
- #read_with_options(report, obj) ⇒ Object
Constructor Details
#initialize(*args, &blk) ⇒ Column
Returns a new instance of Column.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/report/body/column.rb', line 10 def initialize(*args, &blk) if block_given? @blk = blk end @body = args.shift @name = args.shift = args. @method_id = .delete(:method_id) || args.shift @faded = .delete(:faded) @row_options = end |
Instance Attribute Details
#blk ⇒ Object (readonly)
Returns the value of attribute blk.
7 8 9 |
# File 'lib/report/body/column.rb', line 7 def blk @blk end |
#body ⇒ Object (readonly)
Returns the value of attribute body.
4 5 6 |
# File 'lib/report/body/column.rb', line 4 def body @body end |
#faded ⇒ Object (readonly)
Returns the value of attribute faded.
8 9 10 |
# File 'lib/report/body/column.rb', line 8 def faded @faded end |
#method_id ⇒ Object (readonly)
Returns the value of attribute method_id.
6 7 8 |
# File 'lib/report/body/column.rb', line 6 def method_id @method_id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/report/body/column.rb', line 5 def name @name end |
#row_options ⇒ Object (readonly)
Returns the value of attribute row_options.
9 10 11 |
# File 'lib/report/body/column.rb', line 9 def @row_options end |
Instance Method Details
#read(report, obj) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/report/body/column.rb', line 21 def read(report, obj) if blk case blk.arity when 0 obj.instance_eval(&blk) when 2 blk.call report, obj else raise "column block should have 0 or 2 arguments" end elsif method_id obj.send method_id elsif from_name = guesses.detect { |m| obj.respond_to?(m) } obj.send from_name else raise "#{obj.inspect} does not respond to any of #{guesses.inspect}" end end |
#read_with_options(report, obj) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/report/body/column.rb', line 39 def (report, obj) v = read report, obj f = case faded when Symbol obj.send faded else faded end { :value => v, :faded => f }.merge end |