Module: Finitio::Syntax::Node
- Included in:
- AdType, AnyType, Attribute, BuiltinType, ConstraintDef, Constraints, Contract, Definitions, Expr, Expression, ExternalPair, Heading, HeadingExtra, HighOrderTypeInstantiation, HighOrderVars, Import, Imports, InlinePair, LambdaExpr, Literal, MainType, Metadata, MetadataAttr, NamedConstraint, RelationType, SeqType, SetType, StructType, SubType, System, TupleType, TypeDef, TypeRef, UnionType, UnnamedConstraint
- Defined in:
- lib/finitio/syntax/node.rb
Defined Under Namespace
Modules: ClassHelpers
Class Method Summary collapse
Instance Method Summary collapse
- #metadata ⇒ Object
- #resolve_ruby_const(name) ⇒ Object
- #unique_names!(cs, kind = "constraint") ⇒ Object
Class Method Details
.included(by) ⇒ Object
26 27 28 |
# File 'lib/finitio/syntax/node.rb', line 26 def self.included(by) by.extend(ClassHelpers) end |
Instance Method Details
#metadata ⇒ Object
11 12 13 14 |
# File 'lib/finitio/syntax/node.rb', line 11 def m = captures[:metadata].first m && m.value end |
#resolve_ruby_const(name) ⇒ Object
5 6 7 8 9 |
# File 'lib/finitio/syntax/node.rb', line 5 def resolve_ruby_const(name) name.split('::').inject(::Kernel){|mod,const| mod.const_get(const) } end |
#unique_names!(cs, kind = "constraint") ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/finitio/syntax/node.rb', line 16 def unique_names!(cs, kind = "constraint") names = {} cs.map(&:name).compact.each do |n| names.merge!(n => true) do |k,_,_| raise Error, "Duplicate #{kind} name `#{k}`" end end cs end |