Class: Importer::Error
- Inherits:
-
Object
- Object
- Importer::Error
- Defined in:
- lib/iron/import/error.rb
Instance Attribute Summary collapse
-
#row ⇒ Object
readonly
Returns the value of attribute row.
-
#sheet ⇒ Object
readonly
Returns the value of attribute sheet.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#for_context?(context) ⇒ Boolean
Returns true if this error is for the given context, where context can be a Row, Sheet or Importer instance.
- #importer_level? ⇒ Boolean
-
#initialize(context, text) ⇒ Error
constructor
A new instance of Error.
-
#level ⇒ Object
Returns the level at which this error occurred, one of :row, :sheet, :importer.
- #row_level? ⇒ Boolean
- #sheet_level? ⇒ Boolean
- #summary ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(context, text) ⇒ Error
Returns a new instance of Error.
7 8 9 10 11 12 13 14 15 |
# File 'lib/iron/import/error.rb', line 7 def initialize(context, text) if context.is_a?(Importer::Sheet) @sheet = context elsif context.is_a?(Importer::Row) @row = context @sheet = context.sheet end @text = text.to_s end |
Instance Attribute Details
#row ⇒ Object (readonly)
Returns the value of attribute row.
5 6 7 |
# File 'lib/iron/import/error.rb', line 5 def row @row end |
#sheet ⇒ Object (readonly)
Returns the value of attribute sheet.
5 6 7 |
# File 'lib/iron/import/error.rb', line 5 def sheet @sheet end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
5 6 7 |
# File 'lib/iron/import/error.rb', line 5 def text @text end |
Instance Method Details
#for_context?(context) ⇒ Boolean
Returns true if this error is for the given context, where context can be a Row, Sheet or Importer instance.
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/iron/import/error.rb', line 53 def for_context?(context) case context when Row return @row == context when Sheet return @sheet == context else return true end end |
#importer_level? ⇒ Boolean
47 48 49 |
# File 'lib/iron/import/error.rb', line 47 def importer_level? level == :importer end |
#level ⇒ Object
Returns the level at which this error occurred, one of :row, :sheet, :importer
33 34 35 36 37 |
# File 'lib/iron/import/error.rb', line 33 def level return :row if @row return :sheet if @sheet return :importer end |
#row_level? ⇒ Boolean
39 40 41 |
# File 'lib/iron/import/error.rb', line 39 def row_level? level == :row end |
#sheet_level? ⇒ Boolean
43 44 45 |
# File 'lib/iron/import/error.rb', line 43 def sheet_level? level == :sheet end |
#summary ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/iron/import/error.rb', line 17 def summary summary = '' if @row summary += "#{@sheet} #{@row}: " elsif @sheet summary += "#{@sheet}: " end summary + @text end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/iron/import/error.rb', line 27 def to_s summary end |