Class: NotionRubyMapping::FileObject
- Inherits:
-
Object
- Object
- NotionRubyMapping::FileObject
- Defined in:
- lib/notion_ruby_mapping/objects/file_object.rb
Overview
TextObject
Instance Attribute Summary collapse
-
#file_upload_object ⇒ Object
Returns the value of attribute file_upload_object.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#url ⇒ Object
Returns the value of attribute url.
-
#will_update ⇒ Object
readonly
Returns the value of attribute will_update.
Class Method Summary collapse
-
.file_object(url_or_fuo_or_fo) ⇒ FileObject
Self or created FileObject.
Instance Method Summary collapse
-
#external? ⇒ TrueClass, FalseClass
True if “type” is “external”.
- #initialize(url: nil, file_upload_object: nil, json: {}) ⇒ TextObject constructor
- #property_values_json ⇒ Hash
Constructor Details
#initialize(url: nil, file_upload_object: nil, json: {}) ⇒ TextObject
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/notion_ruby_mapping/objects/file_object.rb', line 8 def initialize(url: nil, file_upload_object: nil, json: {}) if url @type = "external" @url = url elsif file_upload_object @type = "file_upload" @file_upload_object = file_upload_object elsif json @type = json["type"] @url = json[@type]["url"] @expiry_time = json[@type]["expiry_time"] else raise StandardError, "FileObject requires url: or json:" end @will_update = false end |
Instance Attribute Details
#file_upload_object ⇒ Object
Returns the value of attribute file_upload_object.
24 25 26 |
# File 'lib/notion_ruby_mapping/objects/file_object.rb', line 24 def file_upload_object @file_upload_object end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
24 25 26 |
# File 'lib/notion_ruby_mapping/objects/file_object.rb', line 24 def type @type end |
#url ⇒ Object
Returns the value of attribute url.
24 25 26 |
# File 'lib/notion_ruby_mapping/objects/file_object.rb', line 24 def url @url end |
#will_update ⇒ Object (readonly)
Returns the value of attribute will_update.
24 25 26 |
# File 'lib/notion_ruby_mapping/objects/file_object.rb', line 24 def will_update @will_update end |
Class Method Details
.file_object(url_or_fuo_or_fo) ⇒ FileObject
Returns self or created FileObject.
29 30 31 32 33 34 35 36 37 |
# File 'lib/notion_ruby_mapping/objects/file_object.rb', line 29 def self.file_object(url_or_fuo_or_fo) if url_or_fuo_or_fo.is_a? FileUploadObject FileObject.new file_upload_object: url_or_fuo_or_fo elsif url_or_fuo_or_fo.is_a? FileObject url_or_fuo_or_fo else FileObject.new url: url_or_fuo_or_fo end end |
Instance Method Details
#external? ⇒ TrueClass, FalseClass
Returns true if “type” is “external”.
40 41 42 |
# File 'lib/notion_ruby_mapping/objects/file_object.rb', line 40 def external? @type == "external" end |
#property_values_json ⇒ Hash
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/notion_ruby_mapping/objects/file_object.rb', line 63 def property_values_json if @type == "file_upload" { "type" => @type.to_s, @type => { "id" => @file_upload_object.id, }, } else ans = { "type" => @type.to_s, @type => { "url" => @url, }, } ans[@type]["expiry_time"] = @expiry_time if @expiry_time ans end end |