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.



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

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



72
73
74
75
76
77
78
79
# File 'lib/rio/nullio.rb', line 72

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



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

def <<(obj)
  self
end

#binmodeObject



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

def binmode() nil end

#callstr(func, *args) ⇒ Object



154
155
156
# File 'lib/rio/nullio.rb', line 154

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

#closeObject



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

def close
  @open = false
end

#close_read(*objs) ⇒ Object

Raises:

  • (IOError)


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

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

#close_write(*objs) ⇒ Object

Raises:

  • (IOError)


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

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

#closed?Boolean

Returns:

  • (Boolean)


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

def closed?
  not @open
end

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



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

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

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



101
102
103
# File 'lib/rio/nullio.rb', line 101

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

#eof?Boolean

Returns:

  • (Boolean)


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

def eof?()
  true
end

#fcntl(integer_cmd, arg) ⇒ Object



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

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

#filenoObject



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

def fileno() nil end

#flushObject



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

def flush() nil end

#fsyncObject



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

def fsync() nil end

#getcObject



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

def getc() nil end

#gets(sep_string = $/) ⇒ Object

Raises:

  • (IOError)


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

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

#ioctl(integer_cmd, arg) ⇒ Object



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

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

#isattyObject



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

def isatty() false end

#linenoObject



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

def lineno() @lineno end

#lineno=(a) ⇒ Object



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

def lineno=(a) @lineno = a end

#posObject



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

def pos() 0 end

#pos=(n) ⇒ Object



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

def pos=(n) 0 end

Raises:

  • (IOError)


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

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

#printf(fmt, *args) ⇒ Object



151
152
153
# File 'lib/rio/nullio.rb', line 151

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

#puts(*objs) ⇒ Object



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

def puts(*objs)
  nil
end

#readObject



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

def read() nil end

#readcharObject



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

def readchar() nil end

#readline(sep_string = $/) ⇒ Object

Raises:

  • (EOFError)


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

def readline(sep_string=$/)
  raise EOFError
end

#readlines(sep_string = $/) ⇒ Object



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

def readlines(sep_string=$/)
  []
end

#rewindObject



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

def rewind
  @lineno = 0
end

#tty?Boolean

Returns:

  • (Boolean)


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

def tty?() false end

#write(string) ⇒ Object



146
147
148
149
# File 'lib/rio/nullio.rb', line 146

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