class Sway::File
Public Class Methods
new(array_or_hash_path, *options)
click to toggle source
# File lib/sway/file.rb, line 10 def initialize(array_or_hash_path, *options) raise 'Not file path argument.' unless ::File.exist?(array_or_hash_path) @filename_extension = ::File.extname(array_or_hash_path).delete('.') raise 'Sorry, unsupported extension.' unless Extensions::ALL.include?(@filename_extension) @file = ::File.open(array_or_hash_path, 'r').read @options = options.extract_options! filename_extension_instance = create_filename_extension_instance @mash = filename_extension_instance.mash @mashes = filename_extension_instance.mashes end
Private Instance Methods
create_filename_extension_instance()
click to toggle source
# File lib/sway/file.rb, line 22 def create_filename_extension_instance case @filename_extension when *Extensions::YAML Sway::YAML.new(@file) when *Extensions::JSON Sway::JSON.new(@file) when *Extensions::CSV Sway::CSV.new(@file, @options) end end