Class: NotionRubyMapping::FilesProperty
- Includes:
- IsEmptyIsNotEmpty
- Defined in:
- lib/notion_ruby_mapping/files_property.rb
Overview
Select property
Constant Summary collapse
- TYPE =
"files"
Instance Attribute Summary collapse
-
#files ⇒ Object
Returns the value of attribute files.
Attributes inherited from Property
Instance Method Summary collapse
-
#initialize(name, will_update: false, json: nil, files: []) ⇒ FilesProperty
constructor
A new instance of FilesProperty.
- #property_values_json ⇒ Hash
- #update_from_json(json) ⇒ Object
- #url_to_hash(url) ⇒ Hash
Methods included from IsEmptyIsNotEmpty
#filter_is_empty, #filter_is_not_empty
Methods inherited from Property
create_from_json, #make_filter_query, #type
Constructor Details
#initialize(name, will_update: false, json: nil, files: []) ⇒ FilesProperty
Returns a new instance of FilesProperty.
11 12 13 14 |
# File 'lib/notion_ruby_mapping/files_property.rb', line 11 def initialize(name, will_update: false, json: nil, files: []) super name, will_update: will_update @files = json || Array(files).map { |url| url_to_hash url } || [] end |
Instance Attribute Details
#files ⇒ Object
Returns the value of attribute files.
15 16 17 |
# File 'lib/notion_ruby_mapping/files_property.rb', line 15 def files @files end |
Instance Method Details
#property_values_json ⇒ Hash
36 37 38 39 40 41 42 |
# File 'lib/notion_ruby_mapping/files_property.rb', line 36 def property_values_json if @files.map { |f| f["type"] }.include? "file" {} else {@name => {"files" => @files, "type" => "files"}} end end |
#update_from_json(json) ⇒ Object
30 31 32 33 |
# File 'lib/notion_ruby_mapping/files_property.rb', line 30 def update_from_json(json) @will_update = false @files = json["files"] end |
#url_to_hash(url) ⇒ Hash
19 20 21 22 23 24 25 26 27 |
# File 'lib/notion_ruby_mapping/files_property.rb', line 19 def url_to_hash(url) { "name" => url, "type" => "external", "external" => { "url" => url, }, } end |