Class: FortIO::Namelist::Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/fortio-namelist/fortran_namelist.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Reader

Returns a new instance of Reader.



71
72
73
# File 'lib/fortio-namelist/fortran_namelist.rb', line 71

def initialize (text)
  @namelist = FortIO::Namelist::Parser.new.parse(text)
end

Instance Attribute Details

#namelistObject (readonly)

Returns the value of attribute namelist.



85
86
87
# File 'lib/fortio-namelist/fortran_namelist.rb', line 85

def namelist
  @namelist
end

Instance Method Details

#parse(group, out = {}) ⇒ Object



75
76
77
78
79
80
81
82
83
# File 'lib/fortio-namelist/fortran_namelist.rb', line 75

def parse (group, out={})
  group = group.downcase
  raise "no definition of namelist group '#{group}'" \
                                    unless nml = @namelist[group]
  nml.each do |paramdef|
    paramdef.set(out)
  end
  return out
end