"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/ruport/data/record.rb" between
ruport-1.7.1.tar.gz and ruport-1.8.0.tar.gz

About: Ruport (Ruby Reports) is a simple, extensible reporting system built for Rubyists. It provides tools for data acquisition, database interaction, formatting, and parsing/munging.

record.rb  (ruport-1.7.1):record.rb  (ruport-1.8.0)
skipping to change at line 58 skipping to change at line 58
# d = Record.new { "a" => 1, "c" => 3, "b" => 2 } # d = Record.new { "a" => 1, "c" => 3, "b" => 2 }
# d[1] #=> ? (without attributes, you cannot rely on order) # d[1] #=> ? (without attributes, you cannot rely on order)
# d['a'] #=> 1 # d['a'] #=> 1
# d.c #=> 3 # d.c #=> 3
# #
def initialize(data,options={}) def initialize(data,options={})
data = data.dup data = data.dup
case(data) case(data)
when Array when Array
@attributes = options[:attributes] || (0...data.length).to_a @attributes = options[:attributes] || (0...data.length).to_a
@data = @attributes.inject({}) { |h,a| h.merge(a => data.shift) } @data = @attributes.each_with_object({}) { |a, h| h[a.freeze] = data.shi ft }
when Hash when Hash
@data = data.dup @data = data
@attributes = options[:attributes] || data.keys @attributes = options[:attributes] || @data.keys
end end
end end
############## ##############
# Delegators # # Delegators #
############## ##############
# Returns a copy of the <tt>attributes</tt> from this Record. # Returns a copy of the <tt>attributes</tt> from this Record.
# #
# Example: # Example:
skipping to change at line 143 skipping to change at line 143
# or calls the method <tt>foo</tt> # or calls the method <tt>foo</tt>
# #
# record.get("foo") # looks for an attribute "foo" or :foo # record.get("foo") # looks for an attribute "foo" or :foo
# #
# record.get(0) # Gets the first element # record.get(0) # Gets the first element
# #
def get(name) def get(name)
case name case name
when String,Symbol when String,Symbol
self[name] || send(name) self[name] || send(name)
when Fixnum when Integer
self[name] self[name]
else else
raise ArgumentError, "Whatchu Talkin' Bout, Willis?" raise ArgumentError, "Whatchu Talkin' Bout, Willis?"
end end
end end
################ ################
# Conversions # # Conversions #
################ ################
 End of changes. 3 change blocks. 
4 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)