Class: FortranFormatParser::Group

Inherits:
Struct
  • Object
show all
Defined in:
ext/fortio/lib/fortio/fortran_format.rb,
ext/fortio/lib/fortio/fortran_format.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#countObject

Returns the value of attribute count

Returns:

  • (Object)

    the current value of count



127
128
129
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 127

def count
  @count
end

#memberObject

Returns the value of attribute member

Returns:

  • (Object)

    the current value of member



127
128
129
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 127

def member
  @member
end

Instance Method Details

#count_argsObject



165
166
167
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 165

def count_args
  return count*member.inject(0){|s,m| s + m.count_args}
end

#inspectObject



168
169
170
171
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 168

def inspect
  count_str = count == 1 ? "" : count.to_s
  return "#{count_str}(" + member.map{|x| x.inspect}.join(",")+ ')'
end

#read(io, list, state) ⇒ Object



158
159
160
161
162
163
164
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 158

def read (io, list, state)
  count.times do |i|
    member.each do |mem|
      mem.read(io, list, state)
    end
  end
end

#read_as_root(io, list) ⇒ Object



151
152
153
154
155
156
157
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 151

def read_as_root (io, list)
  state = State.new(0, false, false, false, io.pos, false)
  read(io, list, state)
  unless state.continue
    io.gets
  end
end

#write(io, list, state) ⇒ Object



144
145
146
147
148
149
150
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 144

def write (io, list, state)
  count.times do |i|
    member.each do |mem|
      mem.write(io, list, state)
    end
  end
end

#write_as_root(io, list) ⇒ Object



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 129

def write_as_root (io, list)
  state = State.new(0, false, false, false, io.pos, false)
  write(io, list, state)
  if state.continue
    if state.tab_move
     io.string.gsub!(/\000/, ' ')
   end
 else
   if state.tab_move
     io.string.gsub!(/\000/, ' ')
      io.seek(0, IO::SEEK_END)
   end
    io.puts
end
end