Method: RDL::Type::PreciseStringType#initialize
- Defined in:
- lib/rdl/types/string.rb
#initialize(*vals) ⇒ PreciseStringType
For interpolated strings, it will include strings and RDL types, in order, where the types represent the types of the interpolated portions, and the strings represent the surrounding string parts.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rdl/types/string.rb', line 10 def initialize(*vals) @interp = false vals.each { |v| case v when String ## do nothing when Type ## interpolated string @interp = true else raise RuntimeError, "Attempt to create precise string type with non-string or non-type value #{v}" unless vals.all? { |val| val.is_a?(Type) || val.is_a?(String) } end } vals = [vals.join] if !@interp && vals.size > 1 ## if all elements of `vals` are strings, join them into one @vals = vals @ubounds = [] @lbounds = [] @promoted = false @cant_promote = false super() end |