Class: NotionRubyMapping::TextProperty
- Extended by:
- Forwardable
- Includes:
- Enumerable, ContainsDoesNotContain, EqualsDoesNotEqual, IsEmptyIsNotEmpty, StartsWithEndsWith
- Defined in:
- lib/notion_ruby_mapping/text_property.rb
Overview
Text property
Direct Known Subclasses
Instance Attribute Summary collapse
-
#text_objects ⇒ Object
readonly
Returns the value of attribute text_objects.
Attributes inherited from Property
Instance Method Summary collapse
-
#<<(to) ⇒ NotionRubyMapping::RichTextObject
Added RichTextObject.
-
#[](index) ⇒ RichTextObject
Selected RichTextObject.
-
#delete_at(index) ⇒ NotionRubyMapping::RichTextObject
Removed RichTextObject.
- #each(&block) ⇒ Enumerator
-
#full_text ⇒ String
Full_text.
-
#initialize(name, will_update: false, json: nil, text_objects: nil) ⇒ TextProperty
constructor
A new instance of TextProperty.
-
#will_update ⇒ TrueClass, FalseClass
Will update?.
Methods included from IsEmptyIsNotEmpty
#filter_is_empty, #filter_is_not_empty
Methods included from StartsWithEndsWith
#filter_ends_with, #filter_starts_with
Methods included from ContainsDoesNotContain
#filter_contains, #filter_does_not_contain
Methods included from EqualsDoesNotEqual
#filter_does_not_equal, #filter_equals
Methods inherited from Property
create_from_json, #make_filter_query, #type
Constructor Details
#initialize(name, will_update: false, json: nil, text_objects: nil) ⇒ TextProperty
Returns a new instance of TextProperty.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/notion_ruby_mapping/text_property.rb', line 18 def initialize(name, will_update: false, json: nil, text_objects: nil) raise StandardError, "TextObject is abstract class. Please use RichTextProperty." if instance_of? TextProperty super name, will_update: will_update @text_objects = if text_objects text_objects.map { |to_s| RichTextObject.text_object to_s } elsif json json.map { |to| RichTextObject.create_from_json to } else [] end end |
Instance Attribute Details
#text_objects ⇒ Object (readonly)
Returns the value of attribute text_objects.
30 31 32 |
# File 'lib/notion_ruby_mapping/text_property.rb', line 30 def text_objects @text_objects end |
Instance Method Details
#<<(to) ⇒ NotionRubyMapping::RichTextObject
Returns added RichTextObject.
47 48 49 50 51 52 |
# File 'lib/notion_ruby_mapping/text_property.rb', line 47 def <<(to) @will_update = true rto = RichTextObject.text_object(to) @text_objects << rto rto end |
#[](index) ⇒ RichTextObject
Returns selected RichTextObject.
56 57 58 |
# File 'lib/notion_ruby_mapping/text_property.rb', line 56 def [](index) @text_objects[index] end |
#delete_at(index) ⇒ NotionRubyMapping::RichTextObject
Returns removed RichTextObject.
62 63 64 65 |
# File 'lib/notion_ruby_mapping/text_property.rb', line 62 def delete_at(index) @will_update = true @text_objects[index] end |
#each(&block) ⇒ Enumerator
39 40 41 42 43 |
# File 'lib/notion_ruby_mapping/text_property.rb', line 39 def each(&block) return enum_for(:each) unless block @text_objects.each(&block) end |
#full_text ⇒ String
Returns full_text.
68 69 70 |
# File 'lib/notion_ruby_mapping/text_property.rb', line 68 def full_text map(&:text).join "" end |
#will_update ⇒ TrueClass, FalseClass
Returns will update?.
33 34 35 |
# File 'lib/notion_ruby_mapping/text_property.rb', line 33 def will_update @will_update || @text_objects.map(&:will_update).any? end |