Class: FortranFormatParser::NodeA

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



370
371
372
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 370

def count
  @count
end

#lengthObject

Returns the value of attribute length

Returns:

  • (Object)

    the current value of length



370
371
372
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 370

def length
  @length
end

Instance Method Details

#count_argsObject



397
398
399
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 397

def count_args
  return count
end

#inspectObject



400
401
402
403
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 400

def inspect
  count_str = count == 1 ? "" : count.to_s
  return "#{count_str}A#{length}"
end

#read(io, list, state) ⇒ Object



387
388
389
390
391
392
393
394
395
396
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 387

def read (io, list, state)
  str = nil
  if length
    list << (str = io.read(length))
  else
    list << (str = io.read)
  end
rescue
  raise "reading error in fortran format : #{str.dump} for #{self.inspect}"
end

#write(io, list, state) ⇒ Object



372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 372

def write (io, list, state)
  len = length
  if len
    count.times do 
      str = list.shift
      if str.length > len
        io << str[0,len]
      else
        io << str.rjust(len)
      end
    end
  else
    io << str
  end
end