class Twitter::TwitterText::Configuration
Constants
- CONFIG_V1
- CONFIG_V2
- CONFIG_V3
- PARSER_VERSION_CLASSIC
- PARSER_VERSION_DEFAULT
- PARSER_VERSION_EMOJI_PARSING
- PARSER_VERSION_WEIGHTED
Attributes
default_configuration[RW]
default_weight[R]
emoji_parsing_enabled[R]
max_weighted_tweet_length[R]
ranges[R]
scale[R]
transformed_url_length[R]
version[R]
Public Class Methods
configuration_from_file(filename)
click to toggle source
# File lib/twitter-text/configuration.rb, line 50 def self.configuration_from_file(filename) config = parse_file(filename) config ? self.new(config) : nil end
new(config = {})
click to toggle source
# File lib/twitter-text/configuration.rb, line 55 def initialize(config = {}) @version = config[:version] @max_weighted_tweet_length = config[:maxWeightedTweetLength] @scale = config[:scale] @default_weight = config[:defaultWeight] @transformed_url_length = config[:transformedURLLength] @emoji_parsing_enabled = config[:emojiParsingEnabled] @ranges = config[:ranges].map { |range| Twitter::TwitterText::WeightedRange.new(range) } if config.key?(:ranges) && config[:ranges].is_a?(Array) end
parse_file(filename)
click to toggle source
# File lib/twitter-text/configuration.rb, line 45 def self.parse_file(filename) string = File.open(filename, 'rb') { |f| f.read } parse_string(string) end
parse_string(string, options = {})
click to toggle source
# File lib/twitter-text/configuration.rb, line 41 def self.parse_string(string, options = {}) JSON.parse(string, options.merge(symbolize_names: true)) end