次のようなオブジェクトがあります。
class Report
attr_accessor :weekly_stats, :report_times
def initialize
@weekly_stats = Hash.new {|h, k| h[k]={}}
@report_times = Hash.new {|h, k| h[k]={}}
values = []
end
end
weekly_statsとreport_timesをループし、各キーを大文字にしてその値を割り当てたいと思います。
今私はこれを持っています:
report.weekly_stats.map do |attribute_name, value|
report.values <<
{
:name => attribute_name.upcase,
:content => value ||= "Not Currently Available"
}
end
report.report_times.map do |attribute_name, value|
report.values <<
{
:name => attribute_name.upcase,
:content => format_date(value)
}
end
report.values
1つのループで週次統計とレポート時間の両方をマップする方法はありますか?
ありがとう