Class: MDArray::Section

Inherits:
Object
  • Object
show all
Defined in:
lib/mdarray/section.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(netcdf_section) ⇒ Section





33
34
35
# File 'lib/mdarray/section.rb', line 33

def initialize(netcdf_section)
  @netcdf_elmt = netcdf_section
end

Instance Attribute Details

#netcdf_elmtObject (readonly)

Returns the value of attribute netcdf_elmt.



27
28
29
# File 'lib/mdarray/section.rb', line 27

def netcdf_elmt
  @netcdf_elmt
end

Class Method Details

.build(*args) ⇒ Object


Builds a section by passing the proper section definition. The following itens can be part of the section definition shape origin size stride range section spec




49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/mdarray/section.rb', line 49

def self.build(*args)

  opts = Map.options(args)

  shape = opts.getopt(:shape)
  origin = opts.getopt(:origin)
  size = opts.getopt(:size)
  stride = opts.getopt(:stride)
  range = opts.getopt(:range)
  section = opts.getopt(:section)
  spec = opts.getopt(:spec)

  if (spec)
    new(Java::UcarMa2::Section.new(spec))
  elsif (shape)
    if (origin)
      new(Java::UcarMa2::Section.new(origin.to_java(:int), shape.to_java(:int)))
    else
      new(Java::UcarMa2::Section.new(shape.to_java(:int)))
    end
  elsif (origin)
    if (!size || !stride)
      raise "Invalid section definition, size and stride are required"
    end
    new(Java::UcarMa2::Section.new(origin.to_java(:int), size.to_java(:int), 
                                   stride.to_java(:int)))
  elsif (range)
    new(Java::UcarMa2::Section.new(range))
  end

end

Instance Method Details





85
86
87
# File 'lib/mdarray/section.rb', line 85

def print
  p @netcdf_elmt.toString()
end

#to_sObject





93
94
95
# File 'lib/mdarray/section.rb', line 93

def to_s
  @netcdf_elmt.toString()
end