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



512
513
514
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 512

def count
  @count
end

#expObject

Returns the value of attribute exp

Returns:

  • (Object)

    the current value of exp



512
513
514
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 512

def exp
  @exp
end

#lengthObject

Returns the value of attribute length

Returns:

  • (Object)

    the current value of length



512
513
514
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 512

def length
  @length
end

#precObject

Returns the value of attribute prec

Returns:

  • (Object)

    the current value of prec



512
513
514
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 512

def prec
  @prec
end

Instance Method Details

#count_argsObject



532
533
534
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 532

def count_args
  return count
end

#inspectObject



535
536
537
538
539
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 535

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



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

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



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

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