Class: AsciiDataTools::RecordType::Type

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/ascii-data-tools/record_type.rb

Direct Known Subclasses

UnknownType

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, content_fields = Field::Fields.new) ⇒ Type

Returns a new instance of Type.



33
34
35
36
# File 'lib/ascii-data-tools/record_type.rb', line 33

def initialize(name, content_fields = Field::Fields.new)
  @name = name
  @fields_by_type = {:content => content_fields, :meta => make_meta_fields}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



42
43
44
# File 'lib/ascii-data-tools/record_type.rb', line 42

def method_missing(method_name, *args, &block)
  content_fields.send(method_name, *args, &block)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



28
29
30
# File 'lib/ascii-data-tools/record_type.rb', line 28

def name
  @name
end

Instance Method Details

#field_with_name(name) ⇒ Object



38
39
40
# File 'lib/ascii-data-tools/record_type.rb', line 38

def field_with_name(name)
  all_fields.with_name(name)
end

#filename_should_match(value) ⇒ Object



46
47
48
# File 'lib/ascii-data-tools/record_type.rb', line 46

def filename_should_match(value)
  field_with_name(:filename).should_be_constrained_to(value)
end