class Onebox::Engine::GithubGistOnebox::GistFile

Constants

MAX_LINES

Attributes

filename[R]
language[R]

Public Class Methods

new(json) click to toggle source
# File lib/onebox/engine/github_gist_onebox.rb, line 59
def initialize(json)
  @json = json
  @filename = @json["filename"]
  @language = @json["language"]
end

Public Instance Methods

content() click to toggle source
# File lib/onebox/engine/github_gist_onebox.rb, line 65
def content
  lines.take(MAX_LINES).join("\n")
end
truncated?() click to toggle source
# File lib/onebox/engine/github_gist_onebox.rb, line 69
def truncated?
  lines.size > MAX_LINES
end

Private Instance Methods

lines() click to toggle source
# File lib/onebox/engine/github_gist_onebox.rb, line 75
def lines
  @lines ||= @json["content"].split("\n")
end