Skip to content

Instantly share code, notes, and snippets.

@nicolaracco
Created June 28, 2012 06:09
Show Gist options
  • Save nicolaracco/3009437 to your computer and use it in GitHub Desktop.
Save nicolaracco/3009437 to your computer and use it in GitHub Desktop.
#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