0
0
Fork 0

Make Rubella::Input classes respond to each

Also fix some code convetions
This commit is contained in:
Stormwind 2015-04-25 22:41:05 +02:00
parent 9b4ad30a7e
commit 9a013f53fd
2 changed files with 12 additions and 9 deletions

View File

@ -20,7 +20,7 @@ module Rubella
# @param value string A string, which contains the data
# @return Rubella::Input::Base
#
def self.string(value)
def self.string value
raise NotImplementedError.new "Please override 'self.string' in your "+
"concrete implementation"
end
@ -32,11 +32,14 @@ module Rubella
# @param file_name string The name of the file
# @return Rubella:Input::Base
#
def self.file(file_name)
def self.file file_name
raise NotImplementedError.new "Please override 'self.file' in your "+
"concrete implementation"
end
def each &block
@data.each &block
end
end

View File

@ -14,11 +14,11 @@ module Rubella
# is supposed to be private. Please use Rubella::Input::JSON.string or
# Rubella::Input::JSON.file to create a new instance.
#
# @param json__string string A string, which contains the data as json
# @param json_string string A string, which contains the data as json
# @return Rubella::Input::JSON
#
def initialize(json_string)
@data = ::JSON::load(json_string)
def initialize json_string
@data = ::JSON::load json_string
end
# Constructor
@ -26,8 +26,8 @@ module Rubella
#
# @param json_string string A string, which contains the data as json
# @return Rubella::Input::JSON
def self.string(json_string)
self.new(json_string)
def self.string json_string
self.new json_string
end
# Constructor
@ -37,8 +37,8 @@ module Rubella
# @param json_file string The name of the file, which json contains
# @return Rubella:Input::JSON
#
def self.file(json_file)
self.new File.new(json_file, 'r')
def self.file json_file
self.new File.new json_file, 'r'
end
end