if → case
This commit is contained in:
parent
9a08ce176f
commit
413f98c964
1 changed files with 7 additions and 4 deletions
11
repl.rb
11
repl.rb
|
@ -37,21 +37,24 @@ class RplRepl
|
|||
end
|
||||
|
||||
def format_element( elt )
|
||||
if elt[:type] == :numeric && elt[:base] != 10
|
||||
case elt[:type]
|
||||
when :numeric
|
||||
prefix = case elt[:base]
|
||||
when 2
|
||||
'0b'
|
||||
when 8
|
||||
'0o'
|
||||
when 10
|
||||
''
|
||||
when 16
|
||||
'0x'
|
||||
else
|
||||
"0#{elt[:base]}_"
|
||||
end
|
||||
return "#{prefix}#{elt[:value].to_s( elt[:base] )}"
|
||||
"#{prefix}#{elt[:value].to_s( elt[:base] )}"
|
||||
else
|
||||
elt[:value]
|
||||
end
|
||||
|
||||
elt[:value]
|
||||
end
|
||||
|
||||
def print_stack
|
||||
|
|
Loading…
Reference in a new issue