class Relation
Attributes
effects[RW]
helper[RW]
label[RW]
start[RW]
stop[RW]
type[RW]
Public Class Methods
new(relation_array, index)
click to toggle source
# File lib/vispan/relation.rb, line 4 def initialize(relation_array, index) @effects = [] @label = '' extract(relation_array, index) set_helper(index) end
Public Instance Methods
adjust_length(string)
click to toggle source
# File lib/vispan/relation.rb, line 34 def adjust_length(string) if string.length > 30 (20..string.length).step(20) { |limit| if string[limit, string.length - limit].include?(' ') empty = string[limit, string.length - limit].index(' ') string[limit + empty] = "\n" end } end end
extract(relation_array, index)
click to toggle source
# File lib/vispan/relation.rb, line 12 def extract(relation_array, index) @start = set_node(relation_array.shift, index, false) set_connection(relation_array.shift) @stop = set_node(relation_array.shift, index, false) @effects = relation_array.map {|effect| set_node(effect, index, true)} end
get_direction()
click to toggle source
# File lib/vispan/relation.rb, line 45 def get_direction @stop.rank - @start.rank end
set_connection(label_string)
click to toggle source
# File lib/vispan/relation.rb, line 19 def set_connection(label_string) label = label_string.split(':') @type = label.shift.strip.downcase @label = label.join(':').strip if @type.include? 'event' adjust_length(@label) end
set_helper(index)
click to toggle source
# File lib/vispan/relation.rb, line 49 def set_helper(index) @helper = Node.new('helper', @label, index, false) @helper.name = 'helper_' + @helper.name + @stop.name end
set_node(node_string, index, effect_flag)
click to toggle source
# File lib/vispan/relation.rb, line 26 def set_node(node_string, index, effect_flag) node_array = node_string.split(':') type = node_array.shift.strip.downcase label = node_array.join(':').strip adjust_length(label) Node.new(type, label, index, effect_flag) end