我们有一个attr_accessor
的课程。如:
class Class
attr_accessor :x
attr_accessor :y
...
end
我想从这个类的实例创建一个哈希。如:
c.to_attr_hash = { :x => "x", :y => "y" }
怎么可以这样做?
答案 0 :(得分:-1)
def set_status_of_day(late_policy,early_departure_policy)
if late_policy.warning_on_late == "Half Day" && early_departure_policy.warning_on_late == "Half Day"
self.status_of_day = "Absent"
elsif late_policy.warning_on_late == "Half Day" && early_departure_policy.warning_on_late == "Present"
self.status_of_day = "Half Day"
elsif late_policy.warning_on_late == "Half Day" && early_departure_policy.warning_on_late == "Early Departure"
self.status_of_day = "Half Day"
elsif late_policy.warning_on_late == "Late" && early_departure_policy.warning_on_late == "Early Departure"
self.status_of_day = "Half Day"
elsif late_policy.warning_on_late == "Present" && early_departure_policy.warning_on_late == "Present"
self.status_of_day = "Present"
.
.
.
.
.
.
.
end
end