class IO::Mode

Constants

NAMES

Attributes

flags[R]

Public Class Methods

new(flags) click to toggle source
# File lib/ole/support.rb, line 210
def initialize flags
  flags = IO.parse_mode flags.to_str if flags.respond_to? :to_str
  raise ArgumentError, "invalid flags - #{flags.inspect}" unless Fixnum === flags
  @flags = flags
end

Public Instance Methods

append?() click to toggle source
# File lib/ole/support.rb, line 229
def append?
  (@flags & APPEND) != 0
end
binary?() click to toggle source
# File lib/ole/support.rb, line 237
def binary?
  (@flags & BINARY) != 0
end
create?() click to toggle source
# File lib/ole/support.rb, line 233
def create?
  (@flags & CREAT) != 0
end
inspect() click to toggle source

# revisit this def apply io

if truncate?
  io.truncate 0
elsif append?
  io.seek IO::SEEK_END, 0
end

end

# File lib/ole/support.rb, line 252
def inspect
  names = NAMES.map { |name| name if (flags & Mode.const_get(name.upcase)) != 0 }
  names.unshift 'rdonly' if (flags & 0x3) == 0
  "#<#{self.class} #{names.compact * '|'}>"
end
readable?() click to toggle source
# File lib/ole/support.rb, line 221
def readable?
  (@flags & WRONLY) == 0
end
truncate?() click to toggle source
# File lib/ole/support.rb, line 225
def truncate?
  (@flags & TRUNC) != 0
end
writeable?() click to toggle source
# File lib/ole/support.rb, line 216
def writeable?
  #(@flags & RDONLY) == 0
  (@flags & 0x3) != RDONLY
end