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.



70
71
72
73
74
# File 'lib/onebox/engine/github_gist_onebox.rb', line 70

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

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



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

def filename
  @filename
end

#languageObject (readonly)

Returns the value of attribute language.



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

def language
  @language
end

Instance Method Details

#contentObject



76
77
78
# File 'lib/onebox/engine/github_gist_onebox.rb', line 76

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

#truncated?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/onebox/engine/github_gist_onebox.rb', line 80

def truncated?
  lines.size > MAX_LINES
end