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 64
def initialize(the_class, parser_type)
  raise "unknown parser type #{parser_type}" unless parser_abilities[parser_type]

  @the_class      = the_class
  @parser_type    = parser_type
  @validator      = DSLFieldValidator.new(the_class, self)
  @endian_handler = DSLBigAndLittleEndianHandler.new(the_class)
  @endian         = nil
end

Public Instance Methods

dsl_params() click to toggle source
# File lib/bindata/dsl.rb, line 109
def dsl_params
  send(parser_abilities[@parser_type].at(0))
end
endian(endian = nil) click to toggle source
# File lib/bindata/dsl.rb, line 76
def endian(endian = nil)
  if endian
    set_endian(endian)
  elsif @endian.nil?
    pendian = parent_attribute(:endian, nil)
    set_endian(pendian) if pendian
  end
  @endian
end
fields() click to toggle source
# File lib/bindata/dsl.rb, line 99
def fields
  unless defined? @fields
    fields = @endian_handler.ancestor_fields || parent_attribute(:fields)
    @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 86
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
method_missing(*args, &block) click to toggle source
# File lib/bindata/dsl.rb, line 113
def method_missing(*args, &block)
  if endian == :big_and_little
    @endian_handler.forward_field_definition(*args, &block)
  else
    parse_and_append_field(*args, &block)
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.