Module: Steep::TypeConstruction::Types
- Defined in:
- lib/steep/type_construction.rb
Class Method Summary collapse
- .any ⇒ Object
- .array_instance(type) ⇒ Object
- .array_instance?(type) ⇒ Boolean
- .boolean?(type) ⇒ Boolean
- .hash_instance(key, value) ⇒ Object
- .hash_instance?(type) ⇒ Boolean
- .nil_instance ⇒ Object
- .optional(type) ⇒ Object
- .range_instance(type) ⇒ Object
- .string_instance ⇒ Object
- .symbol_instance ⇒ Object
Class Method Details
.array_instance(type) ⇒ Object
22 23 24 |
# File 'lib/steep/type_construction.rb', line 22 def array_instance(type) AST::Types::Name.new_instance(name: "::Array", args: [type]) end |
.array_instance?(type) ⇒ Boolean
51 52 53 |
# File 'lib/steep/type_construction.rb', line 51 def array_instance?(type) type.is_a?(AST::Types::Name) && type.name.is_a?(TypeName::Instance) && type.name.name == ModuleName.new(name: "Array", absolute: true) end |
.boolean?(type) ⇒ Boolean
34 35 36 |
# File 'lib/steep/type_construction.rb', line 34 def boolean?(type) type.is_a?(AST::Types::Boolean) end |
.hash_instance(key, value) ⇒ Object
26 27 28 |
# File 'lib/steep/type_construction.rb', line 26 def hash_instance(key, value) AST::Types::Name.new_instance(name: "::Hash", args: [key, value]) end |
.hash_instance?(type) ⇒ Boolean
42 43 44 45 46 47 48 49 |
# File 'lib/steep/type_construction.rb', line 42 def hash_instance?(type) case type when AST::Types::Name type.name.is_a?(TypeName::Instance) && type.name.name == ModuleName.new(name: "Hash", absolute: true) else false end end |
.nil_instance ⇒ Object
14 15 16 |
# File 'lib/steep/type_construction.rb', line 14 def nil_instance AST::Types::Nil.new end |
.optional(type) ⇒ Object
38 39 40 |
# File 'lib/steep/type_construction.rb', line 38 def optional(type) AST::Types::Union.build(types: [type, nil_instance]) end |
.range_instance(type) ⇒ Object
30 31 32 |
# File 'lib/steep/type_construction.rb', line 30 def range_instance(type) AST::Types::Name.new_instance(name: "::Range", args: [type]) end |
.string_instance ⇒ Object
18 19 20 |
# File 'lib/steep/type_construction.rb', line 18 def string_instance AST::Types::Name.new_instance(name: "::String") end |
.symbol_instance ⇒ Object
10 11 12 |
# File 'lib/steep/type_construction.rb', line 10 def symbol_instance AST::Types::Name.new_instance(name: "::Symbol") end |