Class: RIO::NullIO

Inherits:
Object show all
Defined in:
lib/rio/nullio.rb

Overview

:nodoc: all

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(a = nil, m = 'r') ⇒ NullIO

Returns a new instance of NullIO.



53
54
55
56
57
58
# File 'lib/rio/nullio.rb', line 53

def initialize(a=nil,m='r')
#      p "#{callstr('initialize',a,m)} hnd=#{@hnd.inspect}"
  @lineno = 0
  @open = true
  @mode = NullIOMode.new(m)
end

Class Method Details

.open(a = nil, m = 'r', &block) ⇒ Object



61
62
63
64
65
66
67
68
# File 'lib/rio/nullio.rb', line 61

def self.open(a=nil,m='r',&block)
  rtn = io = new(a,m)
  if block_given?
    rtn = yield(io)
    io.close
  end
  rtn
end

Instance Method Details

#<<(obj) ⇒ Object



129
130
131
# File 'lib/rio/nullio.rb', line 129

def <<(obj)
  self
end

#binmodeObject



139
# File 'lib/rio/nullio.rb', line 139

def binmode() nil end

#callstr(func, *args) ⇒ Object



143
144
145
# File 'lib/rio/nullio.rb', line 143

def callstr(func,*args)
  self.class.to_s+'['+self.to_s+']'+'.'+func.to_s+'('+args.join(',')+')'
end

#closeObject



84
85
86
# File 'lib/rio/nullio.rb', line 84

def close
  @open = false
end

#close_read(*objs) ⇒ Object

Raises:

  • (IOError)


121
122
123
124
# File 'lib/rio/nullio.rb', line 121

def close_read(*objs)
  raise IOError,"NullIO is not a duplex stream"
  nil
end

#close_write(*objs) ⇒ Object

Raises:

  • (IOError)


125
126
127
128
# File 'lib/rio/nullio.rb', line 125

def close_write(*objs)
  raise IOError,"NullIO is not a duplex stream"
  nil
end

#closed?Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/rio/nullio.rb', line 81

def closed?
  not @open
end

#each_byte(sep_string = $/, &block) ⇒ Object



93
94
95
# File 'lib/rio/nullio.rb', line 93

def each_byte(sep_string=$/,&block) 
  nil
end

#each_line(sep_string = $/, &block) ⇒ Object Also known as: each



90
91
92
# File 'lib/rio/nullio.rb', line 90

def each_line(sep_string=$/,&block) 
  self
end

#eof?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/rio/nullio.rb', line 87

def eof?()
  true
end

#fcntl(integer_cmd, arg) ⇒ Object



96
97
98
# File 'lib/rio/nullio.rb', line 96

def fcntl(integer_cmd,arg)
  raise NotSupportedException,NotSupportedException.emsg('fcntl',self)
end

#filenoObject



69
# File 'lib/rio/nullio.rb', line 69

def fileno() nil end

#flushObject



70
# File 'lib/rio/nullio.rb', line 70

def flush() nil end

#fsyncObject



71
# File 'lib/rio/nullio.rb', line 71

def fsync() nil end

#getcObject



79
# File 'lib/rio/nullio.rb', line 79

def getc() nil end

#gets(sep_string = $/) ⇒ Object

Raises:

  • (IOError)


103
104
105
106
# File 'lib/rio/nullio.rb', line 103

def gets(sep_string=$/)
  raise IOError,"NullIO is not open for reading" unless @mode.can_read?
  nil
end

#ioctl(integer_cmd, arg) ⇒ Object



99
100
101
# File 'lib/rio/nullio.rb', line 99

def ioctl(integer_cmd,arg)
  raise NotSupportedException,NotSupportedException.emsg('fcntl',self)
end

#isattyObject



72
# File 'lib/rio/nullio.rb', line 72

def isatty() false end

#linenoObject



59
# File 'lib/rio/nullio.rb', line 59

def lineno() @lineno end

#lineno=(a) ⇒ Object



60
# File 'lib/rio/nullio.rb', line 60

def lineno=(a) @lineno = a end

#posObject



74
# File 'lib/rio/nullio.rb', line 74

def pos() 0 end

#pos=(n) ⇒ Object



75
# File 'lib/rio/nullio.rb', line 75

def pos=(n) 0 end

Raises:

  • (IOError)


117
118
119
120
# File 'lib/rio/nullio.rb', line 117

def print(*objs)
  raise IOError,"NullIO is not open for writing" unless @mode.can_write?
  nil
end

#printf(fmt, *args) ⇒ Object



140
141
142
# File 'lib/rio/nullio.rb', line 140

def printf(fmt,*args)
  print(sprintf(fmt,*args))
end

#puts(*objs) ⇒ Object



132
133
134
# File 'lib/rio/nullio.rb', line 132

def puts(*objs)
  nil
end

#readObject



78
# File 'lib/rio/nullio.rb', line 78

def read() nil end

#readcharObject



77
# File 'lib/rio/nullio.rb', line 77

def readchar() nil end

#readline(sep_string = $/) ⇒ Object

Raises:

  • (EOFError)


107
108
109
# File 'lib/rio/nullio.rb', line 107

def readline(sep_string=$/)
  raise EOFError
end

#readlines(sep_string = $/) ⇒ Object



111
112
113
# File 'lib/rio/nullio.rb', line 111

def readlines(sep_string=$/)
  []
end

#rewindObject



114
115
116
# File 'lib/rio/nullio.rb', line 114

def rewind
  @lineno = 0
end

#tty?Boolean

Returns:

  • (Boolean)


73
# File 'lib/rio/nullio.rb', line 73

def tty?() false end

#write(string) ⇒ Object



135
136
137
138
# File 'lib/rio/nullio.rb', line 135

def write(string)
  print(string)
  string.size
end