Class: FortranFormatParser::NodeE

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



514
515
516
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 514

def count
  @count
end

#expObject

Returns the value of attribute exp

Returns:

  • (Object)

    the current value of exp



514
515
516
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 514

def exp
  @exp
end

#lengthObject

Returns the value of attribute length

Returns:

  • (Object)

    the current value of length



514
515
516
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 514

def length
  @length
end

#precObject

Returns the value of attribute prec

Returns:

  • (Object)

    the current value of prec



514
515
516
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 514

def prec
  @prec
end

Instance Method Details

#count_argsObject



534
535
536
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 534

def count_args
  return count
end

#inspectObject



537
538
539
540
541
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 537

def inspect
  count_str = count == 1 ? "" : count.to_s
  exp_str   = (exp.nil? or exp == 2) ? "" :  "E#{exp}"
  return "#{count_str}E#{length}.#{prec}#{exp_str}"
end

#read(io, list, state) ⇒ Object



522
523
524
525
526
527
528
529
530
531
532
533
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 522

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

#write(io, list, state) ⇒ Object



516
517
518
519
520
521
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 516

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