Class: Hyperloop::Console::CodeHistoryItem
Constant Summary
Hyperloop::Component::VERSION
Instance Attribute Summary
Attributes inherited from CodeMirror
#editor
Instance Method Summary
collapse
Instance Method Details
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/hyperloop/console/client_components.rb', line 102
def format
case params.item_type
when :eval
params.value
when :exception
format_lines("!!", params.value)
when :result
format_lines(">>", params.value)
else
format_lines("#{params.item_type}:", params.value)
end
end
|
115
116
117
118
119
120
121
|
# File 'lib/hyperloop/console/client_components.rb', line 115
def format_lines(prefix, value)
fill = prefix.gsub(/./, ' ')
lines = value.split("\n")
(["#{prefix} #{lines.shift}"]+lines.collect do |line|
"#{fill} #{line}"
end).join("\n")
end
|
#mark_response_lines ⇒ Object
123
124
125
126
127
128
129
|
# File 'lib/hyperloop/console/client_components.rb', line 123
def mark_response_lines
return if params.item_type == :eval
lines = params.value.split("\n")
padding = [:exception, :result].include?(params.item_type) ? 3 : 2+params.item_type.to_s.length
last_line = lines[-1] || ''
`#{@editor}.markText({line: 0, ch: 0}, {line: #{lines.count-1}, ch: #{last_line.length+padding}}, {className: 'response-line'})`
end
|