Created
June 28, 2012 06:09
-
-
Save nicolaracco/3009437 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#using excel | |
ExcelFile::Sheet.defile :game_of_thrones_episodes do | |
#dunno @ the moment | |
end | |
ExcelFile::Row.define :episode_row do | |
attribute :name | |
attribute :index | |
attribute :description | |
attribute :boring_level | |
validate :name, :not_empty | |
validate :index, :not_empty, :integer => {:in => [1, 12]} | |
transform :boring_level {|value| value*2 if index < 10} | |
end | |
#using a fixed tabulation file | |
FlatFile::FixedWidth.define :game_of_thrones_episodes do | |
end_line "\r\n" | |
title_row true | |
column_delimiter "" | |
end | |
FlatFile::FixedWidth::Row.define :episode_row do | |
attribute :name, [0, 30] | |
attribute :index, [11, 15] | |
attribute :description, [16, 55] | |
attribute :boring_level, [56, 60] | |
validate :name, :not_empty | |
validate :index, :not_empty, :integer => {:in => [1, 12]} | |
transform :boring_level {|value| value*2 if index < 10} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment