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.


57
58
59
60
61
# File 'lib/onebox/engine/github_gist_onebox.rb', line 57

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

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename


52
53
54
# File 'lib/onebox/engine/github_gist_onebox.rb', line 52

def filename
  @filename
end

#languageObject (readonly)

Returns the value of attribute language


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

def language
  @language
end

Instance Method Details

#contentObject


63
64
65
# File 'lib/onebox/engine/github_gist_onebox.rb', line 63

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

#truncated?Boolean

Returns:

  • (Boolean)

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

def truncated?
  lines.size > MAX_LINES
end