Class: NotionRubyMapping::NumberProperty
- Includes:
- EqualsDoesNotEqual, GreaterThanLessThan, IsEmptyIsNotEmpty
- Defined in:
- lib/notion_ruby_mapping/properties/number_property.rb
Overview
Number property
Constant Summary collapse
- TYPE =
"number"
Instance Attribute Summary
Attributes inherited from Property
#name, #property_cache, #property_id, #will_update
Instance Method Summary collapse
-
#format ⇒ String
New or settled format.
-
#format=(format) ⇒ String
Settled format.
-
#initialize(name, will_update: false, base_type: "page", json: nil, format: nil, property_id: nil, property_cache: nil) ⇒ NumberProperty
constructor
A new instance of NumberProperty.
- #number ⇒ Numeric, ...
-
#number=(num) ⇒ Numeric
Settled number.
- #property_values_json ⇒ Hash
- #update_from_json(json) ⇒ NotionRubyMapping::NumberProperty
- #update_property_schema_json ⇒ Hash
Methods included from IsEmptyIsNotEmpty
#filter_is_empty, #filter_is_not_empty
Methods included from GreaterThanLessThan
#filter_greater_than, #filter_greater_than_or_equal_to, #filter_less_than, #filter_less_than_or_equal_to
Methods included from EqualsDoesNotEqual
#filter_does_not_equal, #filter_equals
Methods inherited from Property
#assert_database_property, #assert_page_property, #clear_will_update, #contents?, create_from_json, #database?, #make_filter_query, #new_name=, #page?, #property_schema_json, #remove, #retrieve_page_property, #type
Constructor Details
#initialize(name, will_update: false, base_type: "page", json: nil, format: nil, property_id: nil, property_cache: nil) ⇒ NumberProperty
Returns a new instance of NumberProperty.
56 57 58 59 60 61 62 |
# File 'lib/notion_ruby_mapping/properties/number_property.rb', line 56 def initialize(name, will_update: false, base_type: "page", json: nil, format: nil, property_id: nil, property_cache: nil) super name, will_update: will_update, base_type: base_type, property_id: property_id, property_cache: property_cache @json = json @json ||= {"format" => format || "number"} if database? end |
Instance Method Details
#format ⇒ String
Returns new or settled format.
25 26 27 28 |
# File 'lib/notion_ruby_mapping/properties/number_property.rb', line 25 def format assert_database_property __method__ @json["format"] end |
#format=(format) ⇒ String
Returns settled format.
33 34 35 36 37 |
# File 'lib/notion_ruby_mapping/properties/number_property.rb', line 33 def format=(format) assert_database_property __method__ @will_update = true @json["format"] = format end |
#number ⇒ Numeric, ...
17 18 19 |
# File 'lib/notion_ruby_mapping/properties/number_property.rb', line 17 def number @json end |
#number=(num) ⇒ Numeric
Returns settled number.
44 45 46 47 48 |
# File 'lib/notion_ruby_mapping/properties/number_property.rb', line 44 def number=(num) assert_page_property __method__ @will_update = true @json = num end |
#property_values_json ⇒ Hash
88 89 90 91 |
# File 'lib/notion_ruby_mapping/properties/number_property.rb', line 88 def property_values_json assert_page_property __method__ {@name => {"number" => @json, "type" => "number"}} end |
#update_from_json(json) ⇒ NotionRubyMapping::NumberProperty
66 67 68 69 70 |
# File 'lib/notion_ruby_mapping/properties/number_property.rb', line 66 def update_from_json(json) @will_update = false @json = json["number"] self end |
#update_property_schema_json ⇒ Hash
75 76 77 78 79 80 81 82 83 |
# File 'lib/notion_ruby_mapping/properties/number_property.rb', line 75 def update_property_schema_json assert_database_property __method__ ans = super return ans if ans != {} || !@will_update ans[@name] ||= {} ans[@name]["number"] = @json ans end |