Class: Dhall::TypeChecker::RecordSelection::Selector
- Inherits:
-
Object
- Object
- Dhall::TypeChecker::RecordSelection::Selector
- Defined in:
- lib/dhall/typecheck.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type) ⇒ Selector
constructor
A new instance of Selector.
- #select(selector) ⇒ Object
Constructor Details
#initialize(type) ⇒ Selector
Returns a new instance of Selector.
549 550 551 |
# File 'lib/dhall/typecheck.rb', line 549 def initialize(type) @fetch_from = type.record end |
Class Method Details
.for(annotated_record) ⇒ Object
539 540 541 542 543 544 545 546 547 |
# File 'lib/dhall/typecheck.rb', line 539 def self.for(annotated_record) if annotated_record.type == Builtins[:Type] TypeSelector.new(annotated_record.value) elsif annotated_record.type.class == Dhall::RecordType new(annotated_record.type) else raise TypeError, "RecordSelection on #{annotated_record.type}" end end |
Instance Method Details
#select(selector) ⇒ Object
553 554 555 556 557 |
# File 'lib/dhall/typecheck.rb', line 553 def select(selector) @fetch_from.fetch(selector) do raise TypeError, "#{@fetch_from} has no field #{@selector}" end end |