Class: RIO::Mode::Base

Inherits:
Object show all
Extended by:
Forwardable
Defined in:
lib/rio/iomode.rb

Direct Known Subclasses

Int, Str

Instance Method Summary collapse

Constructor Details

#initialize(arg) ⇒ Base

Returns a new instance of Base.



46
47
48
49
50
51
52
# File 'lib/rio/iomode.rb', line 46

def initialize(arg)
  if arg.kind_of? self.class
    copy(arg)
  else
    @mode = arg
  end
end

Instance Method Details

#allows_read?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/rio/iomode.rb', line 68

def allows_read?()
  primarily_read? or allows_both?
end

#allows_write?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/rio/iomode.rb', line 71

def allows_write?()
  primarily_write? or allows_both?
end

#copy(other) ⇒ Object



54
55
56
# File 'lib/rio/iomode.rb', line 54

def copy(other)
  @mode = other.mode
end

#read_only?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/rio/iomode.rb', line 62

def read_only?()
  allows_read? and !allows_write?
end

#to_sObject



58
# File 'lib/rio/iomode.rb', line 58

def to_s() @mode.to_s end

#write_only?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/rio/iomode.rb', line 65

def write_only?()
  !allows_read? and allows_read?
end