class Kojo::Form
The Form
class handles interactive ERBX templates
Attributes
file[R]
Public Class Methods
new(file)
click to toggle source
# File lib/kojo/form.rb, line 9 def initialize(file) @file = file end
Public Instance Methods
content()
click to toggle source
# File lib/kojo/form.rb, line 13 def content @content ||= content! end
content!()
click to toggle source
# File lib/kojo/form.rb, line 17 def content! content = File.read file ruby_code = File.exist?("#{file}.rb") ? File.read("#{file}.rb") : nil content = "<%-\n#{ruby_code}\n-%>\n#{content}" if ruby_code content end
method_missing(method_name, *args, **kargs, &block)
click to toggle source
Calls superclass method
# File lib/kojo/form.rb, line 36 def method_missing(method_name, *args, **kargs, &block) if respond_to? method_name prompt.send method_name, *args, **kargs, &block else super end end
prompt()
click to toggle source
# File lib/kojo/form.rb, line 32 def prompt @prompt ||= TTY::Prompt.new end
render()
click to toggle source
# File lib/kojo/form.rb, line 24 def render ERBX.new(content).result(binding) rescue TTY::Reader::InputInterrupt # :nocov: raise Kojo::Interrupt # :nocov: end
respond_to?(method_name, include_private = false)
click to toggle source
Calls superclass method
# File lib/kojo/form.rb, line 44 def respond_to?(method_name, include_private = false) prompt.respond_to?(method_name) || super end
select(*args, &block)
click to toggle source
Below are TTY::Prompt functions that are not captured by the `mthod_missing`, so we specify them explicitly
# File lib/kojo/form.rb, line 51 def select(*args, &block) prompt.select *args, &block end
warn(*args, &block)
click to toggle source
# File lib/kojo/form.rb, line 55 def warn(*args, &block) prompt.warn *args, &block end