6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/numerals/format/input.rb', line 6
def read(*args)
options = {}
args.each do |arg|
case arg
when String
options.merge! text: arg
when Hash
options.merge! arg
else
options.merge! type: arg
end
end
text = options[:text]
options[:type] ||= options[:as]
selector = options[:context] || options[:type]
conversion = Conversions[selector, options[:type_options]]
if conversion
type = conversion.type
else
type = options[:type]
if type != Numeral
raise Format::InvalidNumericType, "Invalid type #{selector.inspect}"
end
end
text_parts = Format.disassemble(@notation, self, text)
numeral = partition_in(text_parts)
if type == Numeral
return numeral
else
conversion_in(numeral, options)
end
end
|