Class: Readwise::Document

Inherits:
Struct
  • Object
show all
Defined in:
lib/readwise/document.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#authorObject

Returns the value of attribute author

Returns:

  • (Object)

    the current value of author



4
5
6
# File 'lib/readwise/document.rb', line 4

def author
  @author
end

#categoryObject

Returns the value of attribute category

Returns:

  • (Object)

    the current value of category



4
5
6
# File 'lib/readwise/document.rb', line 4

def category
  @category
end

#created_atObject

Returns the value of attribute created_at

Returns:

  • (Object)

    the current value of created_at



4
5
6
# File 'lib/readwise/document.rb', line 4

def created_at
  @created_at
end

#htmlObject

Returns the value of attribute html

Returns:

  • (Object)

    the current value of html



4
5
6
# File 'lib/readwise/document.rb', line 4

def html
  @html
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



4
5
6
# File 'lib/readwise/document.rb', line 4

def id
  @id
end

#image_urlObject

Returns the value of attribute image_url

Returns:

  • (Object)

    the current value of image_url



4
5
6
# File 'lib/readwise/document.rb', line 4

def image_url
  @image_url
end

#locationObject

Returns the value of attribute location

Returns:

  • (Object)

    the current value of location



4
5
6
# File 'lib/readwise/document.rb', line 4

def location
  @location
end

#notesObject

Returns the value of attribute notes

Returns:

  • (Object)

    the current value of notes



4
5
6
# File 'lib/readwise/document.rb', line 4

def notes
  @notes
end

#parent_idObject

Returns the value of attribute parent_id

Returns:

  • (Object)

    the current value of parent_id



4
5
6
# File 'lib/readwise/document.rb', line 4

def parent_id
  @parent_id
end

#published_dateObject

Returns the value of attribute published_date

Returns:

  • (Object)

    the current value of published_date



4
5
6
# File 'lib/readwise/document.rb', line 4

def published_date
  @published_date
end

#reading_progressObject

Returns the value of attribute reading_progress

Returns:

  • (Object)

    the current value of reading_progress



4
5
6
# File 'lib/readwise/document.rb', line 4

def reading_progress
  @reading_progress
end

#site_nameObject

Returns the value of attribute site_name

Returns:

  • (Object)

    the current value of site_name



4
5
6
# File 'lib/readwise/document.rb', line 4

def site_name
  @site_name
end

#sourceObject

Returns the value of attribute source

Returns:

  • (Object)

    the current value of source



4
5
6
# File 'lib/readwise/document.rb', line 4

def source
  @source
end

#source_urlObject

Returns the value of attribute source_url

Returns:

  • (Object)

    the current value of source_url



4
5
6
# File 'lib/readwise/document.rb', line 4

def source_url
  @source_url
end

#summaryObject

Returns the value of attribute summary

Returns:

  • (Object)

    the current value of summary



4
5
6
# File 'lib/readwise/document.rb', line 4

def summary
  @summary
end

#tagsObject

Returns the value of attribute tags

Returns:

  • (Object)

    the current value of tags



4
5
6
# File 'lib/readwise/document.rb', line 4

def tags
  @tags
end

#titleObject

Returns the value of attribute title

Returns:

  • (Object)

    the current value of title



4
5
6
# File 'lib/readwise/document.rb', line 4

def title
  @title
end

#updated_atObject

Returns the value of attribute updated_at

Returns:

  • (Object)

    the current value of updated_at



4
5
6
# File 'lib/readwise/document.rb', line 4

def updated_at
  @updated_at
end

#urlObject

Returns the value of attribute url

Returns:

  • (Object)

    the current value of url



4
5
6
# File 'lib/readwise/document.rb', line 4

def url
  @url
end

#word_countObject

Returns the value of attribute word_count

Returns:

  • (Object)

    the current value of word_count



4
5
6
# File 'lib/readwise/document.rb', line 4

def word_count
  @word_count
end

Instance Method Details

#article?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/readwise/document.rb', line 89

def article?
  category == 'article'
end

#book?Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/readwise/document.rb', line 93

def book?
  category == 'book'
end

#child?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/readwise/document.rb', line 57

def child?
  !parent?
end

#created_at_timeObject



31
32
33
34
35
# File 'lib/readwise/document.rb', line 31

def created_at_time
  return unless created_at

  Time.parse(created_at)
end

#email?Boolean

Returns:

  • (Boolean)


97
98
99
# File 'lib/readwise/document.rb', line 97

def email?
  category == 'email'
end

#epub?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/readwise/document.rb', line 77

def epub?
  category == 'epub'
end

#highlight?Boolean

Returns:

  • (Boolean)


105
106
107
# File 'lib/readwise/document.rb', line 105

def highlight?
  category == 'highlight'
end

#in_archive?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/readwise/document.rb', line 69

def in_archive?
  location == 'archive'
end

#in_later?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/readwise/document.rb', line 65

def in_later?
  location == 'later'
end

#in_new?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/readwise/document.rb', line 61

def in_new?
  location == 'new'
end

#note?Boolean

Returns:

  • (Boolean)


109
110
111
# File 'lib/readwise/document.rb', line 109

def note?
  category == 'note'
end

#parent?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/readwise/document.rb', line 53

def parent?
  parent_id.nil?
end

#pdf?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/readwise/document.rb', line 73

def pdf?
  category == 'pdf'
end

#published_date_timeObject



43
44
45
46
47
# File 'lib/readwise/document.rb', line 43

def published_date_time
  return unless published_date

  Time.at(published_date/1000)
end

#read?(threshold: 0.85) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/readwise/document.rb', line 49

def read?(threshold: 0.85)
  reading_progress >= threshold
end

#rss?Boolean

Returns:

  • (Boolean)


101
102
103
# File 'lib/readwise/document.rb', line 101

def rss?
  category == 'rss'
end

#serializeObject



113
114
115
# File 'lib/readwise/document.rb', line 113

def serialize
  to_h
end

#tweet?Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/readwise/document.rb', line 81

def tweet?
  category == 'tweet'
end

#updated_at_timeObject



37
38
39
40
41
# File 'lib/readwise/document.rb', line 37

def updated_at_time
  return unless updated_at

  Time.parse(updated_at)
end

#video?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/readwise/document.rb', line 85

def video?
  category == 'video'
end