Ruby

Rubyコードスクリーンショット生成

Rubyのスニペットを、Macから離れることなく共有したくなる画像に。

Ruby は画像にするのにとても向いた言語です。Ruby らしい書き方は短く、伝えたいことがたいてい 3 行か 4 行で見えるからです。

Codeshotは貼り付けたコードからRubyを判別するので、言語の選び間違いは起きません。付属する30種類のうち3つのテーマで同じスニペットを、アプリ自身のスタイルシートで表示しています。

class Snapshot
  attr_reader :code, :theme

  def initialize(code, theme: "xcode", scale: 2)
    @code, @theme, @scale = code, theme, scale
  end

  def export(path)
    Renderer.render(code, theme).save(path, scale: @scale)
  end
end
Atom One · ダーク
class Snapshot
  attr_reader :code, :theme

  def initialize(code, theme: "xcode", scale: 2)
    @code, @theme, @scale = code, theme, scale
  end

  def export(path)
    Renderer.render(code, theme).save(path, scale: @scale)
  end
end
GitHub · ダーク
class Snapshot
  attr_reader :code, :theme

  def initialize(code, theme: "xcode", scale: 2)
    @code, @theme, @scale = code, theme, scale
  end

  def export(path)
    Renderer.render(code, theme).save(path, scale: @scale)
  end
end
Solarized · ダーク

Rubyに合うテーマ選び

行数が少ないぶん、フォントを大きくしても内容全体が収まります。枠を埋めることに使わず、その余裕は読みやすさのほうに回してください。

サイズを正しく決める

画像サイズを内容に合わせるか、比率で固定します(1:1、4:3、3:2、16:9、9:16、2:3、3:4)。そのうえで1×・2×・3×から選んで書き出せば、Retinaディスプレイでも鮮明なままです。Cでクリップボードに直接コピー、またはSで保存できます。

30種類のテーマを見比べるか、全体の流れをご覧ください。

Rubyと、ほかの59言語のために

すべてMac上で動作します。コードが外に出ることはありません。

macOS版をダウンロード