Module: Zenlish::Feature::FeatureStructDefBearer

Included in:
Lang, Lex::Lexeme, WClasses::WordClass
Defined in:
lib/zenlish/feature/feature_struct_def_bearer.rb

Overview

Mix-in module. It adds a feature structure defintion to its host and also factory methods to ease feature definition manipulation.

Instance Method Summary collapse

Instance Method Details

#[](aName) ⇒ Feature::FeatureDef, NilClass

Retrieve feature definition with given name.

Parameters:

  • aName (String)

    Name of feature def to search for.

Returns:



32
33
34
# File 'lib/zenlish/feature/feature_struct_def_bearer.rb', line 32

def [](aName)
  struct[aName]
end

#booleanFeature::BooleanDomain



37
38
39
# File 'lib/zenlish/feature/feature_struct_def_bearer.rb', line 37

def boolean
  BooleanDomain.instance
end

#enumeration(*items) ⇒ Feature::EnumerationDomain



42
43
44
# File 'lib/zenlish/feature/feature_struct_def_bearer.rb', line 42

def enumeration(*items)
  EnumerationDomain.new(*items)
end

#feature_def(aPair) ⇒ Object

Parameters:

  • aPair (Hash)

    hash with one pair { String => FeatureDomain }



51
52
53
54
55
56
57
58
59
60
# File 'lib/zenlish/feature/feature_struct_def_bearer.rb', line 51

def feature_def(aPair)
  if aPair.values[0].is_a?(Array)
    dom, val = aPair.values[0]
    val = dom.build_value(val) unless val.kind_of?(FeatureValue)
    featr_def = FeatureDef.new(aPair.keys[0], dom, val)
  else
    featr_def = FeatureDef.new(aPair.keys[0], aPair.values[0])
  end
  @struct.add_feature_def(featr_def)
end

#feature_def_dsl(&aBlock) ⇒ Object



62
63
64
# File 'lib/zenlish/feature/feature_struct_def_bearer.rb', line 62

def feature_def_dsl(&aBlock)
  instance_eval(&aBlock)
end

#identifier(_default_value = nil) ⇒ Object



46
47
48
# File 'lib/zenlish/feature/feature_struct_def_bearer.rb', line 46

def identifier(_default_value = nil)
  IdentifierDomain.instance
end

#init_struct_def(aParentStruct, aFeatureHash) ⇒ Object

Parameters:

  • aParentStruct (Feature::FeatureStructDef)

    parent structure

  • aFeatureHash (Hash)

    hash with pairs of the form: String => FeatureDomain



17
18
19
20
21
22
# File 'lib/zenlish/feature/feature_struct_def_bearer.rb', line 17

def init_struct_def(aParentStruct, aFeatureHash)
  @struct = FeatureStructDef.new(aParentStruct)
  aFeatureHash.each_pair do |name, domain|
    feature_def(name => domain)
  end
end

#structFeature::FeatureStructDef



25
26
27
# File 'lib/zenlish/feature/feature_struct_def_bearer.rb', line 25

def struct
  @struct
end