Class: FortranFormatParser::NodeF

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



483
484
485
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 483

def count
  @count
end

#lengthObject

Returns the value of attribute length

Returns:

  • (Object)

    the current value of length



483
484
485
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 483

def length
  @length
end

#precObject

Returns the value of attribute prec

Returns:

  • (Object)

    the current value of prec



483
484
485
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 483

def prec
  @prec
end

Instance Method Details

#count_argsObject



503
504
505
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 503

def count_args
  return count
end

#inspectObject



506
507
508
509
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 506

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

#read(io, list, state) ⇒ Object



491
492
493
494
495
496
497
498
499
500
501
502
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 491

def read (io, list, state)
  str = nil
  count.times do
    str = io.read(length)
    if state.zero 
      str = str.gsub(/ /,'0')
    end
    list << FortranFormat.read_F(str, state.scale, length, prec)
  end
rescue
  raise "reading error in fortran format : #{str.dump} for #{self.inspect}"
end

#write(io, list, state) ⇒ Object



485
486
487
488
489
490
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 485

def write (io, list, state)
  count.times do
    str = FortranFormat.write_F(state.sign, state.scale, length, prec, list.shift)
    io << FortranFormat.check_length(length, str)
  end
end