Class: NotionRubyMapping::FileObject
- Inherits:
-
Object
- Object
- NotionRubyMapping::FileObject
- Defined in:
- lib/notion_ruby_mapping/objects/file_object.rb
Overview
TextObject
Instance Attribute Summary collapse
-
#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_fo) ⇒ FileObject
Self or created FileObject.
Instance Method Summary collapse
-
#external? ⇒ TrueClass, FalseClass
True if “type” is “external”.
- #initialize(url: nil, json: {}) ⇒ TextObject constructor
- #property_values_json ⇒ Hash
Constructor Details
#initialize(url: nil, json: {}) ⇒ TextObject
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/notion_ruby_mapping/objects/file_object.rb', line 8 def initialize(url: nil, json: {}) if url @type = "external" @url = url 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
#type ⇒ Object (readonly)
Returns the value of attribute type.
21 22 23 |
# File 'lib/notion_ruby_mapping/objects/file_object.rb', line 21 def type @type end |
#url ⇒ Object
Returns the value of attribute url.
21 22 23 |
# File 'lib/notion_ruby_mapping/objects/file_object.rb', line 21 def url @url end |
#will_update ⇒ Object (readonly)
Returns the value of attribute will_update.
21 22 23 |
# File 'lib/notion_ruby_mapping/objects/file_object.rb', line 21 def will_update @will_update end |
Class Method Details
.file_object(url_or_fo) ⇒ FileObject
Returns self or created FileObject.
26 27 28 29 30 31 32 |
# File 'lib/notion_ruby_mapping/objects/file_object.rb', line 26 def self.file_object(url_or_fo) if url_or_fo.is_a? FileObject url_or_fo else FileObject.new url: url_or_fo end end |
Instance Method Details
#external? ⇒ TrueClass, FalseClass
Returns true if “type” is “external”.
35 36 37 |
# File 'lib/notion_ruby_mapping/objects/file_object.rb', line 35 def external? @type == "external" end |
#property_values_json ⇒ Hash
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/notion_ruby_mapping/objects/file_object.rb', line 49 def property_values_json ans = { "type" => @type, @type => { "url" => @url, }, } ans[@type]["expiry_time"] = @expiry_time if @expiry_time ans end |