Tapping into Ruby from the JVM

ruby on tap

Concise, tight logic

if options.fetch :squash, true
  result.shift && @lineno += 1 while (top = result[0]) && top.empty?
  result.pop while (bot = result[-1]) && bot.empty?
end

DSLs FTW!

block {
  named :shout
  on_context :paragraph
  parse_content_as :simple
  name_attributes 'vol'
  process &-> (parent, reader, attrs) {
    volume = ((attrs.delete 'vol') || 1).to_i
    create_paragraph parent, (reader.lines.map {|line|
        line.upcase.gsub /\.(?= |$)/, '!' * volume }), attrs
  }
}