Sha256: e1da82d20d683c6afdfbad8dbf13dc24cc467d46f71922ebfa9b20fa00766c7d
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
require_relative "store" require_relative "api" module Hackpad module Cli class UndefinedPad < StandardError end class UnknownFormat < StandardError end class Pad attr_reader :id, :content, :guest_policy, :moderated def initialize(id) @id = id end def title @title ||= (@content.lines.first.strip if @content) end def chars @content.length if @content end def lines @content.lines.count if @content end def load(ext, refresh=false) raise UnknownFormat unless FORMATS.include? ext raise UndefinedPad unless @id if refresh or !Store.exists? ext, id @content = Api.read id, ext Store.save self, ext options = Api.read_options id @guest_policy = options['guestPolicy'] @moderated = !!options['isModerated'] Store.save_meta @id, options else @content = Store.read id, ext options = Store.read_options id @guest_policy = options['guestPolicy'] @moderated = !!options['isModerated'] end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hackpad-cli-0.0.6 | lib/hackpad/cli/pad.rb |
hackpad-cli-0.0.5 | lib/hackpad/cli/pad.rb |