Class: PasteHub::EntryBase

Inherits:
Object
  • Object
show all
Defined in:
lib/pastehub/syncentry.rb

Direct Known Subclasses

Entry

Instance Method Summary collapse

Constructor Details

#initialize(hostname) ⇒ EntryBase

Returns a new instance of EntryBase.



40
41
42
43
44
# File 'lib/pastehub/syncentry.rb', line 40

def initialize( hostname )
  config = PasteHub::Config.instance
  @hostname = hostname
  @filepath = config.localSyncPath + @hostname + ".dat"
end

Instance Method Details

#decode_body(str) ⇒ Object



50
51
52
# File 'lib/pastehub/syncentry.rb', line 50

def decode_body( str )
  return Base64.decode64( str )
end

#encode_body(bin) ⇒ Object



46
47
48
# File 'lib/pastehub/syncentry.rb', line 46

def encode_body( bin )
  return Base64.strict_encode64( bin ).chomp
end

#gen_header(create_date, bin, encoded) ⇒ Object



54
55
56
57
58
59
60
61
62
# File 'lib/pastehub/syncentry.rb', line 54

def gen_header( create_date, bin, encoded )
  h = Hash.new
  h[ :create_date     ] = create_date
  h[ :create_unixtime ] = create_date.to_i
  h[ :hostname    ] = @hostname
  h[ :bodySize    ] = bin.size()
  h[ :encodedBodySize ] = encoded.size()
  return JSON.dump( h )
end