class Hackpad::Cli::Pad
Attributes
cached_at[R]
content[R]
guest_policy[R]
id[R]
moderated[R]
Public Class Methods
new(id)
click to toggle source
# File lib/hackpad/cli/pad.rb, line 17 def initialize(id) @id = id end
Public Instance Methods
cached?()
click to toggle source
# File lib/hackpad/cli/pad.rb, line 58 def cached? Store.exist? 'meta', @id end
chars()
click to toggle source
# File lib/hackpad/cli/pad.rb, line 25 def chars @content.length if @content end
lines()
click to toggle source
# File lib/hackpad/cli/pad.rb, line 29 def lines @content.lines.count if @content end
load(ext, refresh = false)
click to toggle source
# File lib/hackpad/cli/pad.rb, line 33 def load(ext, refresh = false) fail UnknownFormat unless FORMATS.include? ext fail UndefinedPad unless @id if refresh || !Store.exist?(ext, @id) load_from_provider Api, ext Store.save(self, ext) Store.save_options(@id, @options) else load_from_provider Store, ext end end
load_from_provider(klass, ext)
click to toggle source
# File lib/hackpad/cli/pad.rb, line 45 def load_from_provider(klass, ext) @content = klass.read @id, ext @options = klass.read_options(@id) load_options @options end
load_options(options)
click to toggle source
# File lib/hackpad/cli/pad.rb, line 51 def load_options(options) @guest_policy = options['options']['guestPolicy'] @moderated = options['options']['isModerated'] options['cached_at'] ||= Time.now @cached_at = options['cached_at'] end
title()
click to toggle source
# File lib/hackpad/cli/pad.rb, line 21 def title @title ||= (@content.lines.first.strip if @content) end