Class: Onebox::Engine::GithubGistOnebox::GistFile

Inherits:
Object
  • Object
show all
Defined in:
lib/onebox/engine/github_gist_onebox.rb

Constant Summary collapse

MAX_LINES =
10

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ GistFile

Returns a new instance of GistFile.



59
60
61
62
63
# File 'lib/onebox/engine/github_gist_onebox.rb', line 59

def initialize(json)
  @json = json
  @filename = @json["filename"]
  @language = @json["language"]
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



54
55
56
# File 'lib/onebox/engine/github_gist_onebox.rb', line 54

def filename
  @filename
end

#languageObject (readonly)

Returns the value of attribute language.



55
56
57
# File 'lib/onebox/engine/github_gist_onebox.rb', line 55

def language
  @language
end

Instance Method Details

#contentObject



65
66
67
# File 'lib/onebox/engine/github_gist_onebox.rb', line 65

def content
  lines.take(MAX_LINES).join("\n")
end

#truncated?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/onebox/engine/github_gist_onebox.rb', line 69

def truncated?
  lines.size > MAX_LINES
end