Class: Gonzui::ContentInfo

Inherits:
Struct
  • Object
show all
Extended by:
Util
Defined in:
lib/gonzui/info.rb,
lib/gonzui/info.rb

Constant Summary collapse

PACK_FORMAT =
"w*"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util

assert, assert_equal, assert_equal_all, assert_non_nil, assert_not_reached, benchmark, command_exist?, commify, eprintf, format_bytes, program_name, protect_from_signals, require_command, set_verbosity, shell_escape, unix?, vprintf, windows?, wprintf

Instance Attribute Details

#format_idObject

Returns the value of attribute format_id

Returns:

  • (Object)

    the current value of format_id



46
47
48
# File 'lib/gonzui/info.rb', line 46

def format_id
  @format_id
end

#indexed_pObject

Returns the value of attribute indexed_p

Returns:

  • (Object)

    the current value of indexed_p



46
47
48
# File 'lib/gonzui/info.rb', line 46

def indexed_p
  @indexed_p
end

#itimeObject

Returns the value of attribute itime

Returns:

  • (Object)

    the current value of itime



46
47
48
# File 'lib/gonzui/info.rb', line 46

def itime
  @itime
end

#license_idObject

Returns the value of attribute license_id

Returns:

  • (Object)

    the current value of license_id



46
47
48
# File 'lib/gonzui/info.rb', line 46

def license_id
  @license_id
end

#mtimeObject

Returns the value of attribute mtime

Returns:

  • (Object)

    the current value of mtime



46
47
48
# File 'lib/gonzui/info.rb', line 46

def mtime
  @mtime
end

#nlinesObject

Returns the value of attribute nlines

Returns:

  • (Object)

    the current value of nlines



46
47
48
# File 'lib/gonzui/info.rb', line 46

def nlines
  @nlines
end

#sizeObject

Returns the value of attribute size

Returns:

  • (Object)

    the current value of size



46
47
48
# File 'lib/gonzui/info.rb', line 46

def size
  @size
end

Class Method Details

.dump(size, mtime, itime, format_id, license_id, nlines, indexed_p) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/gonzui/info.rb', line 59

def self.dump(size, mtime, itime, format_id, 
              license_id,  nlines, indexed_p)
  indexed_p = if indexed_p then 1 else 0 end
  # FIXME: It could happen for some cases.
  if mtime < 0
    vprintf("minus mtime found: %d", mtime)
    mtime = Time.now.to_i
  end
  [size, mtime, itime, format_id, 
    license_id, nlines, indexed_p].pack(PACK_FORMAT)
end

.load(dump) ⇒ Object



53
54
55
56
57
# File 'lib/gonzui/info.rb', line 53

def self.load(dump)
  info = self.new(*dump.unpack(PACK_FORMAT))
  info.indexed_p = if info.indexed_p == 1 then true else false end
  return info
end

Instance Method Details

#indexed?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/gonzui/info.rb', line 71

def indexed?
  self.indexed_p
end