class Megam::Reports
Public Class Methods
create(params)
click to toggle source
# File lib/megam/core/reports.rb, line 153 def self.create(params) sps = from_hash(params) sps.create end
from_hash(o)
click to toggle source
# File lib/megam/core/reports.rb, line 138 def self.from_hash(o) sps = self.new(o) sps.from_hash(o) sps end
json_create(o)
click to toggle source
# File lib/megam/core/reports.rb, line 125 def self.json_create(o) sps = new({}) sps.id(o["id"]) if o.has_key?("id") sps.start_date(o["start_date"]) if o.has_key?("start_date") sps.end_date(o["end_date"]) if o.has_key?("end_date") sps.type_of(o["type_of"]) if o.has_key?("type_of") sps.data(o["data"]) if o.has_key?("data") sps.category(o["category"]) if o.has_key?("category") sps.group(o["group"]) if o.has_key?("group") sps.created_at(o["created_at"]) if o.has_key?("created_at") sps end
new(o)
click to toggle source
Calls superclass method
Megam::RestAdapter::new
# File lib/megam/core/reports.rb, line 4 def initialize(o) @id = nil @start_date = nil @end_date = nil @type_of = nil @data = [] @category = nil @group = nil @created_at = nil @some_msg = {} super(o) end
show(params)
click to toggle source
# File lib/megam/core/reports.rb, line 158 def self.show(params) sps = from_hash(params) sps.show end
Public Instance Methods
category(arg=nil)
click to toggle source
# File lib/megam/core/reports.rb, line 61 def category(arg=nil) if arg !=nil @category = arg else @category end end
create()
click to toggle source
# File lib/megam/core/reports.rb, line 163 def create megam_rest.post_reports(to_hash) end
created_at(arg=nil)
click to toggle source
# File lib/megam/core/reports.rb, line 77 def created_at(arg=nil) if arg != nil @created_date = arg else @created_date end end
data(arg = [])
click to toggle source
# File lib/megam/core/reports.rb, line 53 def data(arg = []) if arg != [] @data = arg else @data end end
end_date(arg=nil)
click to toggle source
# File lib/megam/core/reports.rb, line 37 def end_date(arg=nil) if arg != nil @end_date = arg else @end_date end end
error?()
click to toggle source
# File lib/megam/core/reports.rb, line 93 def error? crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error") end
for_json()
click to toggle source
# File lib/megam/core/reports.rb, line 111 def for_json result = { "id" => id, "start_date" => start_date, "end_date" => end_date, "type_of" => type_of, "data" => data, "category" => category, "group" => group, "created_at" => created_at } result end
from_hash(o)
click to toggle source
# File lib/megam/core/reports.rb, line 144 def from_hash(o) @start_date = o[:start_date] if o.has_key?(:start_date) @end_date = o[:end_date] if o.has_key?(:end_date) @type_of = o[:type_of] if o.has_key?(:type_of) @category = o[:category] if o.has_key?(:category) @group = o[:group] if o.has_key?(:group) self end
group(arg=nil)
click to toggle source
# File lib/megam/core/reports.rb, line 69 def group(arg=nil) if arg !=nil @group = arg else @group end end
id(arg=nil)
click to toggle source
# File lib/megam/core/reports.rb, line 21 def id(arg=nil) if arg != nil @id = arg else @id end end
reports()
click to toggle source
# File lib/megam/core/reports.rb, line 17 def reports self end
show()
click to toggle source
# File lib/megam/core/reports.rb, line 167 def show megam_rest.get_reports(to_hash) end
some_msg(arg=nil)
click to toggle source
# File lib/megam/core/reports.rb, line 85 def some_msg(arg=nil) if arg != nil @some_msg = arg else @some_msg end end
start_date(arg=nil)
click to toggle source
# File lib/megam/core/reports.rb, line 29 def start_date(arg=nil) if arg != nil @start_date = arg else @start_date end end
to_hash()
click to toggle source
# File lib/megam/core/reports.rb, line 97 def to_hash index_hash = Hash.new index_hash["start_date"] = start_date index_hash["end_date"] = end_date index_hash["type_of"] = type_of index_hash["category"] = category index_hash["group"] = group index_hash end
to_json(*a)
click to toggle source
# File lib/megam/core/reports.rb, line 107 def to_json(*a) for_json.to_json(*a) end
to_s()
click to toggle source
# File lib/megam/core/reports.rb, line 171 def to_s Megam::Stuff.styled_hash(to_hash) end
type_of(arg=nil)
click to toggle source
# File lib/megam/core/reports.rb, line 45 def type_of(arg=nil) if arg != nil @type_of = arg else @type_of end end