Class: Prune::PObjects::Base
- Inherits:
-
Object
- Object
- Prune::PObjects::Base
show all
- Includes:
- Errors
- Defined in:
- lib/prune/p_objects/base.rb
Constant Summary
collapse
- @@indent =
0
Instance Method Summary
collapse
Instance Method Details
#indent! ⇒ Object
15
16
17
|
# File 'lib/prune/p_objects/base.rb', line 15
def indent!
@@indent += 1
end
|
#outdent! ⇒ Object
19
20
21
|
# File 'lib/prune/p_objects/base.rb', line 19
def outdent!
@@indent -= 1
end
|
#space ⇒ Object
11
12
13
|
# File 'lib/prune/p_objects/base.rb', line 11
def space
" " * @@indent
end
|
#value_to_s(value) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/prune/p_objects/base.rb', line 23
def value_to_s(value)
case value
when String
return value
when PName, PLiteralString, PHexadecimalString
return value.to_s
when PArray, PDictionary
indent!
out = LF + space + value.to_s
outdent!
return out
else
if value.is_a?(Prune::Elements::Base)
return value.reference_id
else
return value.to_s
end
end
end
|