class RubyIdentifier

Attributes

cli_args[R]
token_table[R]

Public Class Methods

new(cli_args, identifier_table) click to toggle source
# File lib/pry-globs/ruby_identifier.rb, line 4
def initialize(cli_args, identifier_table)
  @token_table = identifier_table
  @cli_args = cli_args
end

Public Instance Methods

absent_from_table?() click to toggle source
# File lib/pry-globs/ruby_identifier.rb, line 13
def absent_from_table?
  token_data.nil?
end
absent_msg() click to toggle source
# File lib/pry-globs/ruby_identifier.rb, line 17
def absent_msg
  absent_from_table? ? "There is no information about '#{token}'.\n\nPlease submit data and open a PR!\n" : ''
end
description() click to toggle source
# File lib/pry-globs/ruby_identifier.rb, line 9
def description
  definition + explanation
end

Private Instance Methods

definition() click to toggle source
# File lib/pry-globs/ruby_identifier.rb, line 31
def definition
  token_data['definition']
end
explanation() click to toggle source
# File lib/pry-globs/ruby_identifier.rb, line 39
def explanation
  cli_args.option_present? ? "\n#{token_data['explanation']}" : ''
end
identifier_type() click to toggle source
# File lib/pry-globs/ruby_identifier.rb, line 27
def identifier_type
  @identifier_type ||= (token[0] == '$' ? 'global_variables' : 'constants')
end
token() click to toggle source
# File lib/pry-globs/ruby_identifier.rb, line 23
def token
  cli_args.valid[:identifier_token]
end
token_data() click to toggle source
# File lib/pry-globs/ruby_identifier.rb, line 35
def token_data
  @token_data ||= token_table.data[identifier_type][token]
end