Class: NotionRubyMapping::DateProperty
Overview
Constant Summary
collapse
- TYPE =
"date"
Instance Attribute Summary
Attributes inherited from Property
#name, #will_update
Instance Method Summary
collapse
#filter_after, #filter_before, #filter_does_not_equal, #filter_equals, #filter_next_month, #filter_next_week, #filter_next_year, #filter_on_or_after, #filter_on_or_before, #filter_past_month, #filter_past_week, #filter_past_year
#filter_is_empty, #filter_is_not_empty
Methods inherited from Property
#assert_database_property, #assert_page_property, #clear_will_update, create_from_json, #database?, #make_filter_query, #new_name=, #page?, #property_schema_json, #remove, #type, #update_from_json, #update_property_schema_json
Constructor Details
#initialize(name, will_update: false, base_type: :page, json: nil, start_date: nil, end_date: nil, time_zone: nil) ⇒ DateProperty
Returns a new instance of DateProperty.
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/notion_ruby_mapping/date_property.rb', line 65
def initialize(name, will_update: false, base_type: :page, json: nil, start_date: nil, end_date: nil, time_zone: nil)
super name, will_update: will_update, base_type: base_type
@json = json || {}
return if database?
@json = json || {}
@json["start"] = start_date if start_date
@json["end"] = end_date if end_date
@json["time_zone"] = time_zone if time_zone
end
|
Instance Method Details
#date ⇒ Hash
13
14
15
|
# File 'lib/notion_ruby_mapping/date_property.rb', line 13
def date
@json
end
|
#end_date ⇒ Date, ...
20
21
22
|
# File 'lib/notion_ruby_mapping/date_property.rb', line 20
def end_date
@json["end"]
end
|
#end_date=(edt) ⇒ Object
25
26
27
28
29
30
|
# File 'lib/notion_ruby_mapping/date_property.rb', line 25
def end_date=(edt)
@will_update = true
sdt = start_date
edt = nil if sdt.class != edt.class || sdt > edt
@json["end"] = edt
end
|
#property_values_json ⇒ Hash
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/notion_ruby_mapping/date_property.rb', line 79
def property_values_json
assert_page_property __method__
{
@name => {
"type" => "date",
"date" => {
"start" => value_str(@json["start"]),
"end" => value_str(@json["end"]),
"time_zone" => @json["time_zone"],
},
},
}
end
|
#start_date ⇒ Date, ...
33
34
35
|
# File 'lib/notion_ruby_mapping/date_property.rb', line 33
def start_date
@json["start"]
end
|
#start_date=(sdt) ⇒ Object
38
39
40
41
42
43
|
# File 'lib/notion_ruby_mapping/date_property.rb', line 38
def start_date=(sdt)
@will_update = true
edt = end_date
@json["end"] = nil if sdt.class != edt.class || sdt > edt
@json["start"] = sdt
end
|
#time_zone ⇒ String
46
47
48
|
# File 'lib/notion_ruby_mapping/date_property.rb', line 46
def time_zone
@json["time_zone"]
end
|
#time_zone=(tzone) ⇒ Object
51
52
53
54
|
# File 'lib/notion_ruby_mapping/date_property.rb', line 51
def time_zone=(tzone)
@will_update = true
@json["time_zone"] = tzone
end
|