Class: Cranium::DSL::SourceDefinition
- Inherits:
-
Object
- Object
- Cranium::DSL::SourceDefinition
- Extended by:
- AttributeDSL
- Defined in:
- lib/cranium/dsl/source_definition.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #field(name, type) ⇒ Object
- #file_name_overriden? ⇒ Boolean
-
#initialize(name) ⇒ SourceDefinition
constructor
A new instance of SourceDefinition.
- #resolve_files ⇒ Object
Methods included from AttributeDSL
define_array_attribute, define_attribute, define_boolean_attribute
Constructor Details
#initialize(name) ⇒ SourceDefinition
Returns a new instance of SourceDefinition.
19 20 21 22 23 24 25 26 27 |
# File 'lib/cranium/dsl/source_definition.rb', line 19 def initialize(name) @name = name @file = default_file_name @fields = {} @delimiter = "," @escape = '"' @quote = '"' @encoding = "UTF-8" end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
9 10 11 |
# File 'lib/cranium/dsl/source_definition.rb', line 9 def fields @fields end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
8 9 10 |
# File 'lib/cranium/dsl/source_definition.rb', line 8 def files @files end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/cranium/dsl/source_definition.rb', line 7 def name @name end |
Instance Method Details
#==(other) ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/cranium/dsl/source_definition.rb', line 49 def ==(other) name == other.name and file == other.file and delimiter == other.delimiter and escape == other.escape and quote == other.quote and encoding == other.encoding and fields == other.fields end |
#field(name, type) ⇒ Object
37 38 39 |
# File 'lib/cranium/dsl/source_definition.rb', line 37 def field(name, type) @fields[name] = type end |
#file_name_overriden? ⇒ Boolean
43 44 45 |
# File 'lib/cranium/dsl/source_definition.rb', line 43 def file_name_overriden? @file != default_file_name end |
#resolve_files ⇒ Object
31 32 33 |
# File 'lib/cranium/dsl/source_definition.rb', line 31 def resolve_files @files = Dir[File.join Cranium.configuration.upload_path, @file].map { |file| File.basename file }.sort end |