Parent

Files

Class/Module Index [+]

Quicksearch

BinData::DSLMixin::DSLParser

A DSLParser parses and accumulates field definitions of the form

type name, params

where:

* +type+ is the under_scored name of a registered type
* +name+ is the (possible optional) name of the field
* +params+ is a hash containing any parameters

Attributes

parser_type[R]

Public Class Methods

new(the_class, parser_type) click to toggle source
# File lib/bindata/dsl.rb, line 72
def initialize(the_class, parser_type)
  @the_class   = the_class
  @parser_type = parser_type
  @endian      = parent_attribute(:endian, nil)
end

Public Instance Methods

dsl_params() click to toggle source
# File lib/bindata/dsl.rb, line 113
def dsl_params
  case @parser_type
  when :struct
    to_struct_params
  when :array
    to_array_params
  when :buffer
    to_array_params
  when :choice
    to_choice_params
  when :primitive
    to_struct_params
  else
    raise "unknown parser type #{@parser_type}"
  end
end
endian(endian = nil) click to toggle source
# File lib/bindata/dsl.rb, line 80
def endian(endian = nil)
  if endian.nil?
    @endian
  elsif endian == :big or endian == :little
    @endian = endian
  else
    dsl_raise ArgumentError, "unknown value for endian '#{endian}'"
  end
end
fields() click to toggle source
# File lib/bindata/dsl.rb, line 103
def fields
  unless defined? @fields
    fields = parent_attribute(:fields, nil)
    @fields = SanitizedFields.new(endian)
    @fields.copy_fields(fields) if fields
  end

  @fields
end
hide(*args) click to toggle source
# File lib/bindata/dsl.rb, line 90
def hide(*args)
  if option?(:hidden_fields)
    hidden = args.collect { |name| name.to_sym }

    unless defined? @hide
      @hide = parent_attribute(:hide, []).dup
    end

    @hide.concat(hidden.compact)
    @hide
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.